package com.elite.groovy.callback

import com.elite.groovy.util.EliteBean
import com.elite.groovy.util.Util
import net.sf.json.JSONArray
import net.sf.json.JSONObject
import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory
import com.elite.groovy.kh.KHUtil
import org.springframework.jdbc.core.JdbcTemplate

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse
import java.text.DateFormat
import java.text.DecimalFormat
import java.text.SimpleDateFormat
/**
 *
 * @Title: cn.com.callback-apiDgEChartData
 * @Description:德高Echart图表数据
 * @Author: hcf
 * @Date 2023/10/12 14:59
 *
 */
class apiDgEChartData implements ServiceBackInvoke {
    private static final Log log = LogFactory.getLog(apiDgEChartData.class);
    private static final DATA_SOURCE = "dataSource";

    @Override
    String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {
        String eChartBody = "";
        JSONObject resultJson = new JSONObject();
        response.setCharacterEncoding("UTF-8");
        response.setContentType("application/json;charset=UTF-8");
        String currentDate = "";
        String compareDate = "";
        String compareStartTime = "";
        String compareEndTime = "";
        int compareQuarter = 0;
        int compareAnnual = 0;
        int compareYear = 0;

        //获取入参报文
        eChartBody = Util.getRequestBody(request, 'utf-8');
        log.debug("入参报文：" + eChartBody);
        JSONObject eChartObject = JSONObject.fromObject(eChartBody);
        String reportName = eChartObject.getString("reportName");//报表名称
        String tableName = eChartObject.getString("tableName");
        int reportType = eChartObject.getInt("reportType");//报表类型
        int eChartProportion = eChartObject.getInt("eChartProportion");//比例类型 1.查询，2.同比，3.环比
        int eChartDateType = eChartObject.getInt("eChartDateType");//时间类型 1.月度，2.季度，3.半年度，4.年度
        int quarter = eChartObject.getInt("quarter"); //季度 1.一季度，2.二季度，3.三季度，4.四季度
        int annual = eChartObject.getInt("annual"); //年度 1.上半年，2.下半年
        int year = eChartObject.getInt("year"); //年
        String startTime = eChartObject.getString("startTime");//开始时间
        String endTime = eChartObject.getString("endTime");//结束时间

        String skill = KHUtil.GetSFJV(eChartObject, "skill");//技能组
        JdbcTemplate jt = new JdbcTemplate(eliteBean.getDataSource());

        if (reportType != 0) {
            currentDate = eChartObject.getString("currentDate");//当前数据时间
            compareDate = eChartObject.getString("compareDate");//比较数据时间
            compareQuarter = eChartObject.getInt("compareQuarter"); //同比（环比）季度 1.一季度，2.二季度，3.三季度，4.四季度
            compareAnnual = eChartObject.getInt("compareAnnual"); //同比（环比）年度 1.上半年，2.下半年
            compareStartTime = eChartObject.getString("compareStartTime");//同比开始时间
            compareEndTime = eChartObject.getString("compareEndTime");//同比结束时间
            compareYear = eChartObject.getInt("compareYear");
        }
        switch (reportName) {
            case "zx": //客户咨询类型分析
                String sqltype = eChartObject.getString("sqltype");
                String result = customerConsultReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear,sqltype,skill);
                JSONObject resObject = new JSONObject();
                resObject.put("result", result);
                resultJson = resObject;
                switch (tableName) {
                    case "zx"://咨询报表(表格数据)
                        result = customerConsultTable(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear,sqltype,skill);
                        JSONObject resObjectT = new JSONObject();
                        resObjectT.put("result", result);
                        resultJson = resObjectT;
                        break;
                }
                break;
            case "cppl"://客诉产品品类分析
                String[] result = customerComplaintProductCategoryReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear);
                JSONObject resObject = new JSONObject();
                resObject.put("result1", result[0]);
                resObject.put("result2", result[1]);
                resultJson = resObject;
                switch (tableName) {
                    case "cppl"://客诉区域分析(表格数据)
                        String results = customerComplaintProductCategoryTable(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear);
                        JSONObject resObjectT = new JSONObject();
                        resObjectT.put("result", results);
                        resultJson = resObjectT;
                        break;
                }
                break;
            case "area": //客诉区域分析
                String datedesc = eChartObject.getString("datedesc");//时间中文
                String tb_datedesc = eChartObject.getString("tb_datedesc");//同比时间中文
                JSONObject result = customerComplaintAreaReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear,datedesc,tb_datedesc);
                JSONObject resObject = new JSONObject();
                resObject.put("result", result);
                resultJson = resObject;
                break;
            case "callarea": //客诉区域分析
                String datedesc = eChartObject.getString("datedesc");//时间中文
                String tb_datedesc = eChartObject.getString("tb_datedesc");//同比时间中文
                String callnaturegroup_id = eChartObject.getString("callnaturegroup_id");//小结类型
                JSONObject result = customerCallAreaReport(jt, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear,datedesc,tb_datedesc,callnaturegroup_id);
                JSONObject resObject = new JSONObject();
                resObject.put("result", result);
                resultJson = resObject;
                break;
            case "schedule": //客诉工单进度
                String result = customerComplaintScheduleReport(eliteBean, startTime, endTime, eChartDateType, quarter, annual, year);
                JSONObject resObject = new JSONObject();
                resObject.put("result", result);
                resultJson = resObject;
                break;
            case "zl": //客诉总量趋势
                String tb_startTime = eChartObject.getString("tb_startTime");//开始时间
                String tb_endTime = eChartObject.getString("tb_endTime");//结束时间
                String result = customerComplaintTotalTrendReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, year, compareYear,quarter,tb_startTime, tb_endTime);
                JSONObject resObject = new JSONObject();
                resObject.put("result1", result);
                resultJson = resObject;
                break;
            case "myd": //客诉满意度回访评价
                Map result = satisfactionEvaluateReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear);
                JSONObject resObjectT = new JSONObject();
                resObjectT.put("result1", result.get("result1"));
                resObjectT.put("result2", result.get("result2"));
                resObjectT.put("result3", result.get("result3"));
                resObjectT.put("result4", result.get("result4"));
                resObjectT.put("result5", result.get("result5"));
                resObjectT.put("result6", result.get("result6"));
                resultJson = resObjectT;
                break;
            case "zr": //客诉责任分析
                String result = customerComplaintResponsibilityReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, quarter, annual, compareQuarter, compareAnnual, year, compareYear);
                JSONObject resObject = new JSONObject();
                resObject.put("result1", result);
                resultJson = resObject;
                break;
            case "hw": //话务数据报表
                int month = eChartObject.getInt("month");
                String result = callDetailReport(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, currentDate, compareDate, eChartDateType, quarter, annual, compareQuarter, compareAnnual, month, year, compareYear);
                JSONObject resObject = new JSONObject();
                resObject.put("result", result);
                resultJson = resObject;
                switch (tableName) {
                    case "hw"://话务数据报表(表格数据)
                        result = callDetailTable(eliteBean, startTime, endTime, eChartProportion, compareStartTime, compareEndTime, eChartDateType, quarter, annual, compareQuarter, compareAnnual, month, year, compareYear);
                        JSONObject resObjectT = new JSONObject();
                        resObjectT.put("result", result);
                        resultJson = resObjectT;
                        break;
                }
                break;
            case "jk":
                Map result = workOrderDetailReport(eliteBean, startTime, endTime);
                JSONObject resObjectT = new JSONObject();
                resObjectT.put("result1", result.get("result1"));
                resObjectT.put("result2", result.get("result2"));
                resObjectT.put("result3", result.get("result3"));
                resObjectT.put("result4", result.get("result4"));
                resultJson = resObjectT;
                break;
        }

        return resultJson.toString();
    }

    /**
     * 工单数据监控
     * @return
     */
    Map workOrderDetailReport(EliteBean eliteBean, String startTime, String endTime) {
        JSONObject eChartTooltipJson = new JSONObject();// eChart图Tooltip报文
        JSONObject eChartLegendJson = new JSONObject();// eChart图Legend报文
        JSONArray eChartSeriesArray = new JSONArray(); // eChart图SeriesArray
        JSONObject eChartSeriesJson = new JSONObject();// eChart图SeriesJson
        JSONObject eChartJson = new JSONObject(); // eChart图JSON报文
        JSONObject graphicJson = new JSONObject();
        JSONObject labelLineJson = new JSONObject();
        JSONObject labelJson = new JSONObject();

        JSONObject eChartJson1 = new JSONObject();
        JSONObject eChartSeriesOneJson = new JSONObject();
        JSONObject eChartTooltipJson1 = new JSONObject();
        JSONObject toolboxJson = new JSONObject();
        JSONObject featureJson = new JSONObject();
        JSONObject dataViewJson = new JSONObject();
        JSONObject magicTypeJson = new JSONObject();
        JSONObject restoreJson = new JSONObject();
        JSONObject saveAsImage = new JSONObject();
        JSONObject legendOneJson = new JSONObject();
        JSONArray xAxisArray = new JSONArray();
        JSONObject xAxisJson = new JSONObject();
        JSONObject axisPointerJson = new JSONObject();
        JSONArray yAxisArray = new JSONArray();
        JSONObject yAxisJson = new JSONObject();
        JSONObject yAxisJson1 = new JSONObject();
        JSONArray seriesArray = new JSONArray();
        JSONObject seriesJson1 = new JSONObject();


        JSONObject eChartJson2 = new JSONObject();
        JSONObject eChartSeriesTwoJson = new JSONObject();
        JSONObject legendTwoJson = new JSONObject();
        JSONArray xAxisArray2 = new JSONArray();
        JSONObject xAxisJson2 = new JSONObject();
        JSONArray yAxisArray2 = new JSONArray();
        JSONObject yAxisJson2 = new JSONObject();
        JSONObject yAxisJson3 = new JSONObject();
        JSONArray seriesArray2 = new JSONArray();
        JSONObject seriesJson2 = new JSONObject();

        JSONObject eChartJson3 = new JSONObject();
        JSONObject radarJson = new JSONObject();
        JSONObject dataJson = new JSONObject();
        JSONObject titleJson = new JSONObject();
        JSONObject seriesJson3 = new JSONArray();
        JSONArray indicatorArray = null;
        JSONArray seriesArray3 = new JSONArray();
        JSONArray dataArray = new JSONArray();
        String[] color = ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de"];//颜色
        String[] center = ["50%", "50%"]; //位置
        String[] radius = ["35%", "60%"];
        String[] magicType = ["line", "bar"];
        String[] legendData = ["平均完结耗时", "结案率"];
        String[] legendData2 = ["平均结案时长", "流程超时量"];
        JSONArray array = null;
        JSONArray array1 = null;
        JSONArray array2 = null;
        JSONArray array4 = null;
        String[] arr1 = null;
        String[] arr2 = null;
        String[] arr3 = null;
        String[] arr4 = null;
        String[] arr5 = null;
        String[] arr6 = null;
        int[] arr7 = null;
        try {
            //查询数据(第一张图)
            String sql = '''SELECT
                                w1.workordertype1desc as name,
                                count(tabc.workorderid) as value 
                                FROM
                                    objective o
                                LEFT JOIN 
                                    tabcworkorder tabc ON o.objective_guid = tabc.relation_id
                                LEFT JOIN 
                                    sys_workordertype1 w1 ON tabc.workordertype1 = w1.workordertype1_id
                                where 
                                    tabc.workordertype1 is not null 
                                    and o.createddate >= \'''' + startTime + '''\' and o.createddate <= \'''' + endTime + '''\'
                                GROUP BY
                                w1.workordertype1desc
                                ''';
            List list = eliteBean.chaxun_sql(sql, DATA_SOURCE);
            if (list.size() > 0) {
                array = JSONArray.fromObject(list);
            } else {
                array = new JSONArray();
                array.add(0);
            }
        } catch (Exception e) {
            log.error("第一个sql错误：" + e.getMessage());
        }
        try {
            //查询数据（第二张图）
            String sql1 = '''SELECT
                                WORKORDERTYPE1DESC as name,
                                LEFT (
                                (
                                CASE WHEN (sum(close_Time) = 0 OR sum(colseNum) = 0) 
                                THEN 0 ELSE sum(close_Time) / sum(colseNum) END),
                                8 
                                ) AS  Time,
                                CONCAT(ROUND(sum(OnTimeNum)/ sum(workorderNum), 2) * 100, '%') AS  'LV' 
                                FROM
                                (
                                SELECT
                                t1.RELATION_ID,
                                s1.STAFFNAME,
                                s2.WORKORDERTYPE1DESC,
                                (CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' THEN TIMESTAMPDIFF(SECOND, t1.createddate, t1.MODIFIEDDATE) ELSE 0 END) AS close_Time,
                                (CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' AND t1.MODIFIEDDATE <= t1.EXPECTENDTIME THEN 1 ELSE 0 END) AS OnTimeNum,
                                (CASE WHEN t1.MODIFIEDDATE > t1.EXPECTENDTIME THEN 1 ELSE 0 END) AS timeoutNum,
                                1 AS workorderNum,
                                (CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' THEN 1 ELSE 0 END) AS colseNum,
                                t1.OBJECTIVESTATUS,
                                t1.createddate,
                                t1.MODIFIEDDATE,
                                t1.EXPECTENDTIME 
                                FROM
                                tabcworkorder t1
                                LEFT JOIN staff s1 ON t1.createdby = s1.staff_id
                                LEFT JOIN sys_workordertype1 s2 ON s2.WORKORDERTYPE1_ID = t1.WORKORDERTYPE1 
                                WHERE
                                     t1.createddate >= \'''' + startTime + '''\' and t1.createddate <= \'''' + endTime + '''\'
                                ) ss 
                                GROUP BY
                                WORKORDERTYPE1DESC
                                ''';
            List list1 = eliteBean.chaxun_sql(sql1, DATA_SOURCE);
            if (list1.size() > 0) {
                array1 = JSONArray.fromObject(list1);
                arr1 = new String[list1.size()];
                arr2 = new String[list1.size()];
                arr3 = new String[list1.size()];
                for (int i = 0; i < array1.size(); i++) {
                    JSONObject object = array1.get(i);
                    arr1[i] = object.getString("name");
                    arr2[i] = object.getString("Time");
                    arr3[i] = object.getString("LV");
                }
            }
        } catch (Exception e1) {
            log.error("第2个sql错误：" + e1.getMessage());
        }
        try {
            //查询数据第三张图
            String sql2 = '''SELECT
                                WORKORDERTYPE1DESC as 'name',
                                sum( timeoutNum ) AS timeoutNum,
                                sum(OnTime) as OnTime
                                FROM
                                (
                                SELECT
                                t1.RELATION_ID,
                                s1.STAFFNAME,
                                t1.WORKORDERTYPE1,
                                s2.WORKORDERTYPE1DESC,
                                ( CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' THEN TIMESTAMPDIFF( SECOND, t1.createddate, t1.MODIFIEDDATE ) ELSE 0 END ) AS close_Time,
                                ( CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' AND t1.MODIFIEDDATE <= t1.EXPECTENDTIME THEN 1 ELSE 0 END ) AS OnTimeNum,
                                 (CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' AND t1.MODIFIEDDATE <= t1.EXPECTENDTIME THEN TIMESTAMPDIFF( SECOND, t1.MODIFIEDDATE, t1.EXPECTENDTIME ) ELSE 0 END ) AS OnTime,
                                ( CASE WHEN t1.MODIFIEDDATE > t1.EXPECTENDTIME THEN 1 ELSE 0 END ) AS timeoutNum,
                                1 AS workorderNum,
                                ( CASE WHEN t1.OBJECTIVESTATUS = 'CLOSE' THEN 1 ELSE 0 END ) AS colseNum,
                                t1.OBJECTIVESTATUS,
                                t1.createddate,
                                t1.MODIFIEDDATE,
                                t1.EXPECTENDTIME 
                                FROM
                                tabcworkorder t1
                                LEFT JOIN staff s1 ON t1.createdby = s1.staff_id
                                LEFT JOIN sys_workordertype1 s2 ON s2.WORKORDERTYPE1_ID = t1.WORKORDERTYPE1 
                                WHERE
                                    t1.createddate >= \'''' + startTime + '''\' and t1.createddate <= \'''' + endTime + '''\' 
                                ) ss 
                                GROUP BY
                                WORKORDERTYPE1DESC''';
            List list2 = eliteBean.chaxun_sql(sql2, DATA_SOURCE);
            if (list2.size() > 0) {
                array2 = JSONArray.fromObject(list2);
                arr4 = new String[list2.size()];
                arr5 = new String[list2.size()];
                arr6 = new String[list2.size()];
                for (int i = 0; i < array2.size(); i++) {
                    JSONObject object = array2.get(i);
                    arr4[i] = object.getString("name");
                    arr5[i] = object.getString("timeoutNum");
                    arr6[i] = object.getString("OnTime");
                }
            }
        } catch (Exception e2) {
            log.error("第3个sql错误：" + e2.getMessage());
        }
        try {
            String sql3 = "select WORKORDERSTEPSTATUSDESC as 'name' from sysc_workorderstepstatus group by WORKORDERSTEPSTATUSDESC";
            List list3 = eliteBean.chaxun_sql(sql3, DATA_SOURCE);
            if (list3.size() > 0) {
                arr7 = new int[list3.size()];
                indicatorArray = JSONArray.fromObject(list3);
            }
        } catch (Exception e3) {
            log.error("第4个sql错误：" + e3.getMessage());
        }
        try {
            String sql4 = '''SELECT
                                o.objectivestatus as 'name',
                                count( o.objectivestatus ) as 'value'
                                FROM
                                objective o
                                LEFT JOIN tabcworkorder tabc ON o.objective_guid = tabc.relation_id 
                                where o.createddate >= \'''' + startTime + '''\' and o.createddate <= \'''' + endTime + '''\'
                                GROUP BY
                                o.objectivestatus''';
            List list4 = eliteBean.chaxun_sql(sql4, DATA_SOURCE);
            if (list4.size() > 0) {
                array4 = JSONArray.fromObject(list4);
                for (int i = 0; i < array4.size(); i++) {
                    JSONObject object = array4.get(i);
                    arr7[i] = object.getInt("value");
                }
            }
        } catch (Exception e4) {
            log.error("第5个sql错误：" + e4.getMessage());
        }
        dataArray.add(arr7);

        try {
            //第一张图
            graphicJson.put("type", "text");
            graphicJson.put("left", "center");
            graphicJson.put("top", "center");
            eChartJson.put("graphic", graphicJson);
            //color
            eChartJson.put("color", color);
            //legend
            eChartLegendJson.put("top", "1%");
            eChartLegendJson.put("left", "0%");
            //tooltip
            eChartTooltipJson.put("trigger", "item");
            eChartJson.put("tooltip", eChartTooltipJson);
            //series
            eChartSeriesJson.put("type", "pie");
            eChartSeriesJson.put("radius", radius);
            eChartSeriesJson.put("center", center);
            labelLineJson.put("show", true);
            eChartSeriesJson.put("labelLine", labelLineJson);
            labelJson.put("show", true);
            eChartSeriesJson.put("label", labelJson);
            eChartSeriesJson.put("data", array);
            eChartSeriesArray.add(eChartSeriesJson);
            eChartJson.put("series", eChartSeriesArray);
        } catch (Exception e5) {
            log.error("第一个图错误：" + e5.getMessage());
        }
        try {
            //第二张图
            eChartTooltipJson1.put("trigger", "axis");
            eChartJson1.put("tooltip", eChartTooltipJson1);
            eChartJson1.put("color", color);
            dataViewJson.put("show", true);
            dataViewJson.put("readOnly", false);
            featureJson.put("dataView", dataViewJson);
            magicTypeJson.put("show", true);
            magicTypeJson.put("type", magicType);
            featureJson.put("magicType", magicTypeJson);
            restoreJson.put("show", true);
            featureJson.put("restore", restoreJson);
            saveAsImage.put("show", true);
            featureJson.put("saveAsImage", saveAsImage);
            toolboxJson.put("feature", featureJson);
            eChartJson1.put("toolbox", toolboxJson);
            legendOneJson.put("data", legendData);
            eChartJson1.put("legend", legendOneJson);
            xAxisJson.put("type", "category");
            xAxisJson.put("data", arr1);
            axisPointerJson.put("type", "shadow");
            xAxisJson.put("axisPointer", axisPointerJson);
            xAxisArray.add(xAxisJson);
            eChartJson1.put("xAxis", xAxisArray);
            yAxisJson.put("type", "value");
            yAxisJson.put("name", "平均完结耗时");
            yAxisJson1.put("type", "value");
            yAxisJson1.put("name", "结案率（%）");
            yAxisArray.add(yAxisJson);
            yAxisArray.add(yAxisJson1);
            eChartJson1.put("yAxis", yAxisArray);
            seriesJson1.put("name", "平均完结耗时");
            seriesJson1.put("type", "bar");
            seriesJson1.put("data", arr2);
            eChartSeriesOneJson.put("name", "结案率");
            eChartSeriesOneJson.put("type", "line");
            eChartSeriesOneJson.put("yAxisIndex", 1);
            eChartSeriesOneJson.put("data", arr3);
            seriesArray.add(seriesJson1)
            seriesArray.add(eChartSeriesOneJson);
            eChartJson1.put("series", seriesArray);
        } catch (Exception e6) {
            log.error("第2个图错误：" + e6.getMessage());
        }
        try {
            //第三张张图
            eChartJson2.put("tooltip", eChartTooltipJson1);
            eChartJson2.put("color", color);
            eChartJson2.put("toolbox", toolboxJson);
            legendTwoJson.put("data", legendData2);
            eChartJson2.put("legend", legendTwoJson);
            xAxisJson2.put("type", "category");
            xAxisJson2.put("data", arr4);
            xAxisJson2.put("axisPointer", axisPointerJson);
            xAxisArray2.add(xAxisJson2);
            eChartJson2.put("xAxis", xAxisArray2);
            yAxisJson2.put("type", "value");
            yAxisJson2.put("name", "平均结案时长（h）");
            yAxisJson3.put("type", "value");
            yAxisJson3.put("name", "流程超时量");
            yAxisArray2.add(yAxisJson2);
            yAxisArray2.add(yAxisJson3);
            eChartJson2.put("yAxis", yAxisArray2);
            seriesJson2.put("name", "平均结案时长");
            seriesJson2.put("type", "bar");
            seriesJson2.put("data", arr5);
            eChartSeriesTwoJson.put("name", "流程超时量");
            eChartSeriesTwoJson.put("type", "line");
            eChartSeriesTwoJson.put("yAxisIndex", 1);
            eChartSeriesTwoJson.put("data", arr6);
            seriesArray2.add(seriesJson2)
            seriesArray2.add(eChartSeriesTwoJson);
            eChartJson2.put("series", seriesArray2);
        } catch (Exception e7) {
            log.error("第3个图错误：" + e7.getMessage());
        }
        try {
            //第四张图
            titleJson.put("text", "工单处理类型");
            eChartJson3.put("title", titleJson);
            radarJson.put("indicator", indicatorArray);
            eChartJson3.put("radar", radarJson);
            seriesJson3.put("type", "radar");
            dataJson.put("value", dataArray);
            seriesJson3.put("data", dataJson);
            seriesArray3.add(seriesJson3);
            eChartJson3.put("series", seriesArray3);
        } catch (Exception e8) {
            log.error("第4个图错误：" + e8.getMessage());
        }
        Map map = new HashMap();
        map.put("result1", eChartJson.toString());
        map.put("result2", eChartJson1.toString());
        map.put("result3", eChartJson2.toString());
        map.put("result4", eChartJson3.toString());
        return map;
    }

    /**
     * 客户咨询类型分析
     * @return
     */
    String customerConsultReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear,String sqltype,String skill) {
        JSONObject eChartTitleJson = new JSONObject();// eChart图标题报文
        JSONObject eChartTooltipJson = new JSONObject();// eChart图Tooltip报文
        JSONObject eChartLegendJson = new JSONObject();// eChart图Legend报文
        JSONArray eChartSeriesArray = new JSONArray(); // eChart图SeriesArray
        JSONObject eChartSeriesJson = new JSONObject();// eChart图SeriesJson
        JSONObject eChartSeriesOneJson = new JSONObject();// eChart图SeriesJson
        JSONObject eChartItemStyleJson = new JSONObject();// eChart图ItemStyle样式
        JSONObject eChartJson = new JSONObject(); // eChart图JSON报文
        JSONArray customerConsultArray = null; //eChart图原始数据
        JSONArray customerConsultOneArray = null;//eChart图同比数据
        String[] color = ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de"];//颜色
        String[] centerOne = ["25%", "50%"]; //位置
        String[] centerTwo = ["75%", "50%"]; //位置

        String sql="";
        String sqlOne="";
        String json = "[{\"name\":\"假货举报\",\"value\":0},{\"name\":\"开店咨询\",\"value\":0},{\"name\":\"打假维权协助\",\"value\":0},{\"name\":\"扫码红包\",\"value\":0},{\"name\":\"技术咨询\",\"value\":0},{\"name\":\"投诉与建议\",\"value\":0},{\"name\":\"线索举报\",\"value\":0},{\"name\":\"销售咨询\",\"value\":0},{\"name\":\"防伪异常\",\"value\":0}]";
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }

        //工单数据查询
        String whereSql1="";
        if(!KHUtil.isNull(skill)){
            whereSql1=" and o.createdby in ("+skill+")";
        }
        //小结数据查询
        String whereSql2="";
        if(!KHUtil.isNull(skill)){
            whereSql2=" and ec.Createdby in ("+skill+")";
        }
        //工单数据查询
        if(sqltype.equals("1")){
            sql = ''' SELECT
                            w1.workordertype1desc as name,
                            sum(case when ifnull(tabc.workorderid,'')='' then 0 else 1 end) as value 
                            FROM 
														sys_workordertype1 w1 
														LEFT JOIN 
                                tabcworkorder tabc ON tabc.workordertype1 = w1.workordertype1_id 
														LEFT JOIN 
                                objective o ON o.objective_guid = tabc.relation_id
                            where 
                                tabc.workordertype1 is not null
                                and o.objectivestatus!='FAIL' 
                                and w1.USEFLAG='1'
                                and o.createddate >= \'''' + startTime + '''\' and o.createddate <= \'''' + endTime + '''\' ''' + whereSql1 + '''
           
                            GROUP BY
                            w1.workordertype1desc
                            ''';
        }else{
            //小结数据查询
            sql = ''' select cg.CALLNATUREGROUPDESCRIPTION as name,
                            sum(case when ifnull(ec.EVENTCALLNATURE_GUID,'')='' then 0 else 1 end) as value  
														from Callnaturegroup cg 
														left join Eventcallnature ec on  ec.CALLNATUREGROUP_ID like concat("%",cg.CALLNATUREGROUP_ID,"%")
														where 1=1
														and cg.type='1'
                                and ec.CREATETIME >= \'''' + startTime + '''\' and ec.CREATETIME <= \'''' + endTime + '''\'   ''' + whereSql2 + '''
           
                            GROUP BY cg.CALLNATUREGROUPDESCRIPTION
                            ''';
        }
        List customerConsultList = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (customerConsultList.size() > 0) {
            customerConsultArray = JSONArray.fromObject(customerConsultList);
        } else {
            customerConsultArray = JSONArray.fromObject(json);
        }


        if(sqltype.equals("1")) {
            // 工单同比取数
            sqlOne = '''SELECT
                            w1.workordertype1desc as name,
                            count(tabc.workorderid) as value 
                            FROM
                                objective o
                            LEFT JOIN 
                                tabcworkorder tabc ON o.objective_guid = tabc.relation_id
                            LEFT JOIN 
                                sys_workordertype1 w1 ON tabc.workordertype1 = w1.workordertype1_id
                            where 
                                tabc.workordertype1 is not null 
                                and o.objectivestatus!='FAIL'
                                and w1.USEFLAG='1'
                                and o.createddate >= \'''' + compareStartTime + '''\' and o.createddate <= \'''' + compareEndTime + '''\'
                            GROUP BY
                            w1.workordertype1desc
                            ''';
        }else{
            //同比小结数据查询
            sqlOne = ''' select cg.CALLNATUREGROUPDESCRIPTION as name,
                            sum(case when ifnull(ec.EVENTCALLNATURE_GUID,'')='' then 0 else 1 end) as value  
														from Callnaturegroup cg 
														left join Eventcallnature ec on  ec.CALLNATUREGROUP_ID like concat("%",cg.CALLNATUREGROUP_ID,"%")
														where 1=1
														and cg.type='1'
                                and ec.CREATETIME >= \'''' + compareStartTime + '''\' and ec.CREATETIME <= \'''' + compareEndTime + '''\'
                            GROUP BY cg.CALLNATUREGROUPDESCRIPTION
                            ''';

        }

        List customerConsultListOne = eliteBean.chaxun_sql(sqlOne, DATA_SOURCE);
        if (customerConsultListOne.size() > 0) {
            customerConsultOneArray = JSONArray.fromObject(customerConsultListOne);
        } else {
            customerConsultOneArray = JSONArray.fromObject(json);
        }


        //百分比
        String label='''{
                "normal": {
                "formatter": "{b}：{d}%"
                }
            }'''



        //拼接EChart报文
        if (eChartProportion == 1) {
            //title
            if(sqltype.equals("1")) {
                eChartTitleJson.put("text", "客户咨询类工单分析（图表）");
            }else{
                eChartTitleJson.put("text", "客户咨询类小结分析（图表）");
            }
            eChartTitleJson.put("left", "center");
            eChartJson.put("title", eChartTitleJson);
            //tooltip
            eChartTooltipJson.put("trigger", "item");
            eChartJson.put("tooltip", eChartTooltipJson);
            //legend
            eChartLegendJson.put("top", "bottom");
            // eChartLegendJson.put("left", "center");
            eChartJson.put("legend", eChartLegendJson);
            //color
            eChartJson.put("color", color);
            //series
            eChartSeriesJson.put("type", "pie");
            eChartSeriesJson.put("label", label);
            eChartSeriesJson.put("radius", "50%");
            eChartSeriesJson.put("data", customerConsultArray);
            eChartItemStyleJson.put("shadowBlur", 10);
            eChartItemStyleJson.put("shadowOffsetX", 0);
            eChartItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
            eChartSeriesJson.put("itemStyle", eChartItemStyleJson);
            eChartSeriesArray.add(eChartSeriesJson);
            eChartJson.put("series", eChartSeriesArray);
        } else if (eChartProportion == 2) {
            //title
            if(sqltype.equals("1")) {
                eChartTitleJson.put("text", "客户咨询类工单分析（图表）");
            }else{
                eChartTitleJson.put("text", "客户咨询类小结分析（图表）");
            }
            eChartTitleJson.put("left", "center");
            eChartJson.put("title", eChartTitleJson);
            //tooltip
            eChartTooltipJson.put("trigger", "item");
            eChartJson.put("tooltip", eChartTooltipJson);
            //legend
            eChartLegendJson.put("top", "bottom");
            // eChartLegendJson.put("left", "left");
            eChartJson.put("legend", eChartLegendJson);
            //color
            eChartJson.put("color", color);





            //series1
            eChartSeriesJson.put("type", "pie");
            eChartSeriesJson.put("label", label);
            eChartSeriesJson.put("radius", "50%");
            eChartSeriesJson.put("center", centerOne);
            eChartSeriesJson.put("data", customerConsultArray);
            eChartItemStyleJson.put("shadowBlur", 10);
            eChartItemStyleJson.put("shadowOffsetX", 0);
            eChartItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
            eChartSeriesJson.put("itemStyle", eChartItemStyleJson);
            eChartSeriesArray.add(eChartSeriesJson)

            //series2
            eChartSeriesOneJson.put("type", "pie");
            eChartSeriesOneJson.put("label", label);
            eChartSeriesOneJson.put("radius", "50%");
            eChartSeriesOneJson.put("center", centerTwo);
            eChartSeriesOneJson.put("data", customerConsultOneArray);
            eChartItemStyleJson.put("shadowBlur", 10);
            eChartItemStyleJson.put("shadowOffsetX", 0);
            eChartItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
            eChartSeriesOneJson.put("itemStyle", eChartItemStyleJson);
            eChartSeriesArray.add(eChartSeriesOneJson);
            eChartJson.put("series", eChartSeriesArray);
        }
        return eChartJson.toString();
    }

    /**
     * 客诉产品品类分析
     * @return
     */
    String[] customerComplaintProductCategoryReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear) {
        String[] eChartJsonArr = new String[2];
        /*
        拼接图形的参数
         */
        JSONObject eChartTooltipJsonB = new JSONObject();// eChart图Tooltip报文(饼图)
        JSONArray eChartSeriesArrayB = new JSONArray(); // eChart图SeriesArray(饼图)
        JSONObject eChartSeriesJsonB = new JSONObject();// eChart图SeriesJson(饼图)
        JSONObject eChartNormalJsonB = new JSONObject();// eChart图normalJson(饼图)
        JSONObject eChartLabelJsonB = new JSONObject();// eChart图labelJson(饼图)
        JSONObject eChartNormalLabelJsonB = new JSONObject();// eChart图labelJson(饼图)
        JSONObject eChartNormalLabelLineJsonB = new JSONObject();// eChart图labelJson(饼图)
        JSONObject eChartItemStyleJsonB = new JSONObject();// eChart图ItemStyle样式(饼图)
        JSONObject eChartBigItemStyleJsonB = new JSONObject();// eChart图ItemStyle样式(饼图外层)
        JSONObject eChartJsonB = new JSONObject(); // eChart图JSON报文(饼图)
        JSONObject eChartSeriesTitleJsonB = new JSONObject();// eChart图Series标题报文(饼图)
        JSONObject eChartEmphasisJsonB = new JSONObject();// eChart图eChartEmphasis标题报文(饼图)

        JSONObject eChartSeriesJsonC = new JSONObject();// eChart图SeriesJson(饼图)
        JSONObject eChartNormalJsonC = new JSONObject();// eChart图normalJson(饼图)
        JSONObject eChartNormalLabelJsonC = new JSONObject();// eChart图labelJson(饼图)
        JSONObject eChartNormalLabelLineJsonC = new JSONObject();// eChart图labelJson(饼图)
        JSONObject eChartItemStyleJsonC = new JSONObject();// eChart图ItemStyle样式(饼图)
        JSONObject eChartBigItemStyleJsonC = new JSONObject();// eChart图ItemStyle样式(饼图外层)
        JSONObject eChartSeriesTitleJsonC = new JSONObject();// eChart图Series标题报文(饼图)
        JSONObject eChartEmphasisJsonC = new JSONObject();// eChart图eChartEmphasis标题报文(饼图)

        JSONObject eChartTitleJsonA = new JSONObject();// eChart图标题报文(柱图)
        JSONObject eChartLegendJsonA = new JSONObject();// eChart图Legend报文(柱图)
        JSONObject eChartGridJsonA = new JSONObject();// eChart图Grid报文(柱图)
        JSONArray eChartXAxisArrayA = new JSONArray(); // eChart图xAxisArray(柱图)
        JSONArray eChartYAxisArrayA = new JSONArray(); // eChart图yAxisArray(柱图)
        JSONObject eChartJsonA = new JSONObject(); // eChart图JSON报文(柱图)
        JSONObject eChartTextStyleJsonA = new JSONObject();// eChart图textStyleJson(柱图)
        JSONObject eChartTooltipJsonA = new JSONObject();// eChart图Tooltip(柱图)
        JSONObject eChartAxisPointerA = new JSONObject();// eChart图AxisPointer(柱图)
        JSONObject eChartXAxisJsonA = new JSONObject(); // eChart图xAxisJSON(柱图x轴参数)
        JSONObject eChartAxisTickJsonA = new JSONObject(); // eChart图eChartAxisTickJsonA(柱图x轴参数)
        JSONObject eChartYAxisJsonA = new JSONObject(); // eChart图yAxisJson(柱图y轴参数)
        JSONArray eChartSeriesArrayA = new JSONObject(); // eChart图SeriesArrayA(柱图数据)
        JSONObject eChartSeriesJsonA = new JSONObject();// eChart图SeriesJson(柱图)
        JSONObject eChartSeriesJsonD = new JSONObject();// eChart图SeriesJson(柱图)
        JSONObject eChartItemStyleJsonA = new JSONObject();// eChart图ItemStyle样式(柱图)
        JSONObject eChartNormalJsonA = new JSONObject();// eChart图normalJson(柱图)
        JSONObject eChartNormalLabelJsonA = new JSONObject();// eChart图labelJson(饼图)
        JSONArray customerComplaintProductCategoryArray = null; //eChart图原始数据(柱图)
        JSONArray customerComplaintProductCategoryOneArray = null;//eChart图同比数据(饼图)
        JSONArray customerComplaintProductCategoryTwoArray = null;//eChart图同比数据(柱图)
        JSONArray customerComplaintProductCategoryFourArray = null//eChart图原始数据(饼图)
        /*
            eChart图同比数据处理（饼图）
         */
        JSONArray productCategoryArray = new JSONArray();// eChart图同比数据处理
        JSONObject productCategoryObj = null;
        JSONArray productCategoryArrayOne = new JSONArray();// eChart图原始数据处理
        JSONObject productCategoryObjOne = null;
        String[] color = ["#5470c6", "#91cc75", "#fac858", "#ee6666", "#73c0de"];//颜色
        String[] legendData = [compareDate, currentDate];//legend数据
        String[] centerOne = ["50%", "20%"]; //位置
        String[] centerTwo = ["50%", "60%"]; //位置
        String[] xAxisData = ["德高-防水堵漏", "德高-腻子", "德高-背胶", "德高-美瓷胶", "德高填缝料", "德高-其他"];//柱图
        //柱图同比数据
        int[] valueArr2 = new int[6];
        //柱图原始数据
        int[] valueArr = new int[6];

        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }

        //查询数据
        String sql = '''select
                             DATE_FORMAT(tabc.createddate, '%Y-%m') as '日期',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'FSDL',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'NZ',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'BJ',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'MCJ',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'TFL',
                             sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 'QT'
                            FROM
                             tabcworkorder tabc
                            where 1=1
                             and tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                            GROUP BY
                             DATE_FORMAT(tabc.createddate,'%Y-%m')''';
        List customerComplaintProductCategoryList = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (customerComplaintProductCategoryList.size() > 0) {
            customerComplaintProductCategoryArray = JSONArray.fromObject(customerComplaintProductCategoryList);
            for (int i = 0; i < customerComplaintProductCategoryArray.size(); i++) {
                JSONObject jsonObject = customerComplaintProductCategoryArray.get(i);
                valueArr[0] = jsonObject.getInt("FSDL");//防水堵漏
                valueArr[1] = jsonObject.getInt("NZ");//腻子
                valueArr[2] = jsonObject.getInt("BJ");//背胶
                valueArr[3] = jsonObject.getInt("MCJ");//美瓷胶
                valueArr[4] = jsonObject.getInt("TFL");//填缝料
                valueArr[5] = jsonObject.getInt("QT");//其他
            }
        }
        //饼图数据
        String sqlFour = '''SELECT
                                    tb.date,
                                    tb.`name`,
                                    sum(tb.`value`)as 'value' 
                                    FROM
                                    (
                                    SELECT
                                    t.日期 AS date,
                                    '德高-防水堵漏' AS NAME,
                                    t.德高防水堵漏 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t UNION ALL
                                    SELECT
                                    t1.日期 AS date,
                                    '德高-腻子' AS NAME,
                                    t1.德高腻子 AS 
                                    VALUE
                                    
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                    tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t1 UNION ALL
                                    SELECT
                                    t2.日期 AS date,
                                    '德高-背胶' AS NAME,
                                    t2.德高背胶 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t2 UNION ALL
                                    SELECT
                                    t3.日期 AS date,
                                    '德高-美瓷胶' AS NAME,
                                    t3.德高美瓷胶 AS VALUE   
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                    tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t3 UNION ALL
                                    SELECT
                                    t4.日期 AS date,
                                    '德高-填缝料' AS NAME,
                                    t4.德高填缝料 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                    tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t4 UNION ALL
                                    SELECT
                                    t5.日期 AS date,
                                    '德高-其他' AS NAME,
                                    t5.德高其他 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                    tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t5 
                                   ) tb 
                                    GROUP BY
                                    tb.date,
                                    tb.`name`''';
        List customerComplaintProductCategoryFourList = eliteBean.chaxun_sql(sqlFour, DATA_SOURCE);
        if (customerComplaintProductCategoryFourList.size() > 0) {
            customerComplaintProductCategoryFourArray = JSONArray.fromObject(customerComplaintProductCategoryFourList);
            for (int i = 0; i < customerComplaintProductCategoryFourArray.size(); i++) {
                JSONObject jsonObject = customerComplaintProductCategoryFourArray.get(i);
                productCategoryObjOne = new JSONObject();
                String name = jsonObject.getString("name");
                int value = jsonObject.getInt("value");
                productCategoryObjOne.put("name", name);
                productCategoryObjOne.put("value", value);
                if (value == 0) {
                    JSONObject itemStyleJson = new JSONObject();
                    itemStyleJson.put("color", "#CCCCCC");
                    productCategoryObjOne.put("itemStyle", itemStyleJson);
                    JSONObject labelLineJson = new JSONObject();
                    labelLineJson.put("show", false);
                    productCategoryObjOne.put("labelLine", labelLineJson);
                    JSONObject labelJson = new JSONObject();
                    labelJson.put("show", false);
                    productCategoryObjOne.put("label", labelJson);
                }
                productCategoryArrayOne.add(productCategoryObjOne);
            }
        }
        //同比数据
        if (eChartProportion == 2) {
            String sqlTwo = '''select
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') as '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'FSDL',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'NZ',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'BJ',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'MCJ',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'TFL',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 'QT'
                                   FROM
                                    tabcworkorder tabc
                                   where 
                                     tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                   GROUP BY
                                    DATE_FORMAT(tabc.createddate,'%Y-%m')''';
            List customerComplaintProductCategoryTwoList = eliteBean.chaxun_sql(sqlTwo, DATA_SOURCE);
            if (customerComplaintProductCategoryTwoList.size() > 0) {
                customerComplaintProductCategoryTwoArray = JSONArray.fromObject(customerComplaintProductCategoryTwoList);
                for (int i = 0; i < customerComplaintProductCategoryTwoArray.size(); i++) {
                    JSONObject jsonObject = customerComplaintProductCategoryTwoArray.get(i);
                    valueArr2[0] = jsonObject.getInt("FSDL");//防水堵漏
                    valueArr2[1] = jsonObject.getInt("NZ");//腻子
                    valueArr2[2] = jsonObject.getInt("BJ");//背胶
                    valueArr2[3] = jsonObject.getInt("MCJ");//美瓷胶
                    valueArr2[4] = jsonObject.getInt("TFL");//填缝料
                    valueArr2[5] = jsonObject.getInt("QT");//其他
                }
            }
            //饼图数据
            String sqlOne = '''SELECT
                                    tb.date,
                                    tb.`name`,
                                    sum(tb.`value`)as 'value' 
                                    FROM
                                    (
                                    SELECT
                                    t.日期 AS date,
                                    '德高-防水堵漏' AS NAME,
                                    t.德高防水堵漏 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t UNION ALL
                                    SELECT
                                    t1.日期 AS date,
                                    '德高-腻子' AS NAME,
                                    t1.德高腻子 AS 
                                    VALUE
                                    
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t1 UNION ALL
                                    SELECT
                                    t2.日期 AS date,
                                    '德高-背胶' AS NAME,
                                    t2.德高背胶 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                    tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t2 UNION ALL
                                    SELECT
                                    t3.日期 AS date,
                                    '德高-美瓷胶' AS NAME,
                                    t3.德高美瓷胶 AS VALUE   
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t3 UNION ALL
                                    SELECT
                                    t4.日期 AS date,
                                    '德高-填缝料' AS NAME,
                                    t4.德高填缝料 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE 1=1
                                    and tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t4 UNION ALL
                                    SELECT
                                    t5.日期 AS date,
                                    '德高-其他' AS NAME,
                                    t5.德高其他 AS VALUE
                                    FROM
                                    (
                                    SELECT
                                    DATE_FORMAT(tabc.createddate, '%Y-%m') AS '日期',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS '德高防水堵漏',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS '德高腻子',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS '德高背胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS '德高美瓷胶',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS '德高填缝料',
                                    sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS '德高其他' 
                                    FROM
                                    tabcworkorder tabc 
                                    WHERE
                                     tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                                    GROUP BY
                                    DATE_FORMAT(tabc.createddate, '%Y-%m')) t5 
                                   ) tb 
                                    GROUP BY
                                    tb.date,
                                    tb.`name`''';
            List customerComplaintProductCategoryOneList = eliteBean.chaxun_sql(sqlOne, DATA_SOURCE);
            if (customerComplaintProductCategoryOneList.size() > 0) {
                customerComplaintProductCategoryOneArray = JSONArray.fromObject(customerComplaintProductCategoryOneList);
                for (int i = 0; i < customerComplaintProductCategoryOneArray.size(); i++) {
                    JSONObject jsonObject = customerComplaintProductCategoryOneArray.get(i);
                    productCategoryObj = new JSONObject();
                    String name = jsonObject.getString("name");
                    int value = jsonObject.getInt("value");
                    productCategoryObj.put("name", name);
                    productCategoryObj.put("value", value);
                    if (value == 0) {
                        JSONObject itemStyleJson = new JSONObject();
                        itemStyleJson.put("color", "#CCCCCC");
                        productCategoryObj.put("itemStyle", itemStyleJson);
                        JSONObject labelLineJson = new JSONObject();
                        labelLineJson.put("show", false);
                        productCategoryObj.put("labelLine", labelLineJson);
                        JSONObject labelJson = new JSONObject();
                        labelJson.put("show", false);
                        productCategoryObj.put("label", labelJson);
                    }
                    productCategoryArray.add(productCategoryObj);
                }
            }
        }
        /*
        饼图数据
         */
        //tooltip
        eChartTooltipJsonB.put("trigger", "item");
        eChartJsonB.put("tooltip", eChartTooltipJsonB);
        //label
        eChartLabelJsonB.put("show", true);
        eChartJsonB.put("label", eChartLabelJsonB);
        //color
        eChartJsonB.put("color", color);
        //seriesA
        eChartSeriesJsonB.put("name", compareDate);
        eChartSeriesTitleJsonB.put("text", compareDate);
        eChartSeriesJsonB.put("type", "pie");
        eChartSeriesJsonB.put("radius", "30%");
        eChartSeriesJsonB.put("center", centerOne);
        eChartSeriesJsonB.put("data", productCategoryArrayOne);
        eChartItemStyleJsonB.put("shadowBlur", 10);
        eChartItemStyleJsonB.put("shadowOffsetX", 0);
        eChartItemStyleJsonB.put("shadowColor", "rgba(0, 0, 0, 0.5)");
        eChartEmphasisJsonB.put("itemStyle", eChartItemStyleJsonB);
        eChartSeriesJsonB.put("emphasis", eChartEmphasisJsonB);
        eChartNormalLabelJsonB.put("show", true);
        eChartNormalLabelJsonB.put("formatter", "{b} : {d}%");
        eChartNormalJsonB.put("label", eChartNormalLabelJsonB);
        eChartNormalLabelLineJsonB.put("show", true);
        eChartNormalJsonB.put("labelLine", eChartNormalLabelLineJsonB);
        eChartBigItemStyleJsonB.put("itemStyle", eChartNormalJsonB);
        eChartSeriesArrayB.add(eChartSeriesJsonB);
        //seriesB
        eChartSeriesJsonC.put("name", compareDate);
        eChartSeriesTitleJsonC.put("text", compareDate);
        eChartSeriesJsonC.put("type", "pie");
        eChartSeriesJsonC.put("radius", "30%");
        eChartSeriesJsonC.put("center", centerTwo);
        eChartSeriesJsonC.put("data", productCategoryArray);
        eChartItemStyleJsonC.put("shadowBlur", 10);
        eChartItemStyleJsonC.put("shadowOffsetX", 0);
        eChartItemStyleJsonC.put("shadowColor", "rgba(0, 0, 0, 0.5)");
        eChartEmphasisJsonC.put("itemStyle", eChartItemStyleJsonC);
        eChartSeriesJsonC.put("emphasis", eChartEmphasisJsonC);
        eChartNormalLabelJsonC.put("show", true);
        eChartNormalLabelJsonC.put("formatter", "{b} : {d}%");
        eChartNormalJsonC.put("label", eChartNormalLabelJsonC);
        eChartNormalLabelLineJsonC.put("show", true);
        eChartNormalJsonC.put("labelLine", eChartNormalLabelLineJsonC);
        eChartBigItemStyleJsonC.put("itemStyle", eChartNormalJsonC);
        eChartSeriesArrayB.add(eChartSeriesJsonC);
        eChartJsonB.put("series", eChartSeriesArrayB);

        /*
        柱图数据
         */
        //title
        eChartTitleJsonA.put("text", "客户产品品类分析（图表）");
        eChartTitleJsonA.put("left", "center");
        eChartJsonA.put("title", eChartTitleJsonA);
        //color
        eChartJsonA.put("color", color);
        //tooltip
        eChartTooltipJsonA.put("trigger", "axis");
        eChartAxisPointerA.put("type", "shadow");
        eChartTooltipJsonA.put("axisPointer", eChartAxisPointerA);
        eChartJsonA.put("tooltip", eChartTooltipJsonA);
        //gird
        eChartGridJsonA.put("left", "1%");
        eChartGridJsonA.put("right", "1%");
        eChartGridJsonA.put("bottom", "1%");
        eChartGridJsonA.put("containLabel", true);
        //legend
        eChartLegendJsonA.put("data", legendData);
        eChartLegendJsonA.put("left", "10");
        eChartJsonA.put("legend", eChartLegendJsonA);
        //xAxis
        eChartXAxisJsonA.put("type", "category");
        eChartXAxisJsonA.put("data", xAxisData);
        eChartAxisTickJsonA.put("alignWithLabel", true);
        eChartXAxisJsonA.put("axisTick", eChartAxisTickJsonA);
        eChartXAxisArrayA.add(eChartXAxisJsonA);
        eChartJsonA.put("xAxis", eChartXAxisArrayA);
        //yAxis
        eChartYAxisJsonA.put("type", "value");
        eChartYAxisArrayA.add(eChartYAxisJsonA);
        eChartJsonA.put("yAxis", eChartYAxisArrayA);
        //series1
        eChartSeriesJsonA.put("name", currentDate);
        eChartSeriesJsonA.put("type", "bar");
        eChartSeriesJsonA.put("barWidth", "20%");
        eChartSeriesJsonA.put("data", valueArr);
        eChartNormalLabelJsonA.put("show", true);//开启显示
        eChartNormalLabelJsonA.put("position", "top");//顶部显示
        eChartTextStyleJsonA.put("color", "black");
        eChartTextStyleJsonA.put("fontSize", 12);
        eChartNormalLabelJsonA.put("textStyle", eChartTextStyleJsonA);
        eChartNormalJsonA.put("label", eChartNormalLabelJsonA);
        eChartItemStyleJsonA.put("normal", eChartNormalJsonA);
        eChartSeriesJsonA.put("itemStyle", eChartItemStyleJsonA);
        eChartSeriesArrayA.add(eChartSeriesJsonA);
        //series2
        eChartSeriesJsonD.put("name", currentDate);
        eChartSeriesJsonD.put("type", "bar");
        eChartSeriesJsonD.put("barWidth", "20%");
        eChartSeriesJsonD.put("data", valueArr2);
        eChartNormalLabelJsonA.put("show", true);//开启显示
        eChartNormalLabelJsonA.put("position", "top");//顶部显示
        eChartTextStyleJsonA.put("color", "black");
        eChartTextStyleJsonA.put("fontSize", 12);
        eChartNormalLabelJsonA.put("textStyle", eChartTextStyleJsonA);
        eChartNormalJsonA.put("label", eChartNormalLabelJsonA);
        eChartItemStyleJsonA.put("normal", eChartNormalJsonA);
        eChartSeriesJsonD.put("itemStyle", eChartItemStyleJsonA);
        eChartSeriesArrayA.add(eChartSeriesJsonD);
        eChartJsonA.put("series", eChartSeriesArrayA);
        eChartJsonArr[0] = eChartJsonA.toString();
        eChartJsonArr[1] = eChartJsonB.toString();

        return eChartJsonArr;
    }

    /**
     * 客诉区域分析
     * @return
     */
    JSONObject customerComplaintAreaReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear,String datedesc,String tb_datedesc) {
        log.debug("客诉区域分析")
        JSONObject resObject = new JSONObject();
        //常规查询
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        //同比查询
        if (eChartProportion == 2 && eChartDateType != 1) {
            //常规条件
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            //同比条件
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }
        List belongarealist1;
        //常规数据
        String belongareasql = '''select Regionname,
                                        IFNULL(workcount,0) AS workcount
                                  FROM dg_region dr 
                                  left join 
                                        (select tabc.belongarea,
                                            count(*) as workcount 
                                            from objective o 
                                                left join  tabcworkorder tabc on o.OBJECTIVE_GUID=tabc.relation_id
                                                where tabc.belongarea!='' and o.map_id='M6AP7I' and o.OBJECTIVESTATUS!='FAIL'
                                                and o.createddate >= DATE_FORMAT(\''''+startTime+'''\','%Y-%m-%d 00:00:00') and o.createddate <= DATE_FORMAT(\''''+endTime+'''\','%Y-%m-%d 23:59:59') 
                                                group by tabc.belongarea 
                                                ) tabc on tabc.belongarea=dr.regionid 
                                    where dr.regionid!='AQW011' 
                                    order by OrderNo asc''';
        log.debug("belongareasql:" + belongareasql);
        if (eChartProportion == 2) {
            //同比数据
            String belongareasql1 = '''select Regionname,
                                        IFNULL(workcount,0) AS workcount
                                  FROM dg_region dr 
                                  left join 
                                        (select tabc.belongarea,
                                            count(*) as workcount 
                                            from objective o 
                                                left join  tabcworkorder tabc on o.OBJECTIVE_GUID=tabc.relation_id
                                                where tabc.belongarea!='' and o.map_id='M6AP7I' and o.OBJECTIVESTATUS!='FAIL'
                                                and o.createddate >= DATE_FORMAT(\''''+compareStartTime+'''\','%Y-%m-%d 00:00:00') and o.createddate <= DATE_FORMAT(\''''+compareEndTime+'''\','%Y-%m-%d 23:59:59') 
                                                group by tabc.belongarea 
                                                ) tabc on tabc.belongarea=dr.regionid 
                                    where dr.regionid!='AQW011' 
                                    order by OrderNo asc''';
            log.debug("belongareasql1:" + belongareasql1);
            belongarealist1 = eliteBean.chaxun_sql(belongareasql1, DATA_SOURCE);
            log.debug("belongarealist1" + belongarealist1.size());
        }


        List belongarealist = eliteBean.chaxun_sql(belongareasql, DATA_SOURCE);
        log.debug("belongarealist:" + belongarealist.toString());

        log.debug("belongarealist1:" + belongarealist1.toString());
        String[][] DataTable;
        int ListCount = belongarealist.size();
        //处理Echats图所需数据--初始化数组,分常规和同比
        if (eChartProportion == 2) {
            String[][] DataB = new String[ListCount + 1][4];
            DataB[0][0] = "日期"; //大区
            DataB[0][1] = datedesc; //工单数据
            DataB[0][2] = tb_datedesc;  //同比工单数据
            DataB[0][3] = "增长率";
            double growthRate=0;
            double newValue=0;
            double oldValue=0;

            DecimalFormat df = new DecimalFormat("#.0");
            for (int i = 0; i < belongarealist.size(); i++) {
                DataB[i + 1][0] = belongarealist[i].get("Regionname"); //大区
                DataB[i + 1][1] = belongarealist[i].get("workcount");//工单数据
                DataB[i + 1][2] = belongarealist1[i].get("workcount");//同比工单数据
                newValue = belongarealist1[i].get("workcount");
                oldValue = belongarealist[i].get("workcount");
                //计算增长率
                if(newValue>0&&oldValue>0){
                    growthRate=df.format((newValue-oldValue)/oldValue*100).toDouble();
                }else{
                    growthRate=0.0;
                }
                DataB[i + 1][3] = growthRate; //对比工单
            }
            DataTable = DataB;
            resObject.put("echatsdata", DataB);
        } else {
            String[][] DataB = new String[ListCount + 1][2];
            DataB[0][0] = "日期"; //大区
            DataB[0][1] = datedesc; //工单数据

            for (int i = 0; i < belongarealist.size(); i++) {
                DataB[i + 1][0] = belongarealist[i].get("Regionname"); //大区
                DataB[i + 1][1] = belongarealist[i].get("workcount");//工单数据
            }
            resObject.put("echatsdata", DataB);
        }

        //数据表
        if (eChartProportion == 2) {
            String[][] DataA = new String[4][ListCount + 1];
            DataA[0][0] = "日期"; //表头
            DataA[1][0] = datedesc; //工单
            DataA[2][0] = tb_datedesc; //对比日期
            DataA[3][0] = "增长率"; //
            for (int i = 0; i < belongarealist.size(); i++) {
                DataA[0][i + 1] = belongarealist[i].get("Regionname"); //表头
                DataA[1][i + 1] = belongarealist[i].get("workcount"); //工单
                DataA[2][i + 1] = belongarealist1[i].get("workcount"); //对比工单
                DataA[3][i + 1] = DataTable[i + 1][3]+"%"; //增长率
            }
            resObject.put("tabledata", DataA);
        } else {
            String[][] DataA = new String[2][ListCount + 1];
            DataA[0][0] = "日期"; //表头
            DataA[1][0] = datedesc; //工单
            for (int i = 0; i < belongarealist.size(); i++) {
                DataA[0][i + 1] = belongarealist[i].get("Regionname"); //表头
                DataA[1][i + 1] = belongarealist[i].get("workcount"); //工单
            }
            resObject.put("tabledata", DataA);
        }
        return resObject;
    }



    /**
     * 客户来电小结区域分析
     * @return
     */
    JSONObject customerCallAreaReport(jt, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear,String datedesc,String tb_datedesc,String callnaturegroup_id) {
        log.debug("客户来电小结区域分析")
        JSONObject resObject = new JSONObject();
        //常规查询
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        //同比查询
        if (eChartProportion == 2 && eChartDateType != 1) {
            //常规条件
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            //同比条件
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }
        List belongarealist1,belongarealist2;
        String SQLDSL="";
        if(!callnaturegroup_id.equals("")){
             SQLDSL = ' and ec.CALLNATUREGROUP_ID = '+"'"+callnaturegroup_id+"'"
        }

        //数据SQL
        String belongareasql = '''	select dr.Regionname as Regionname,
                            sum(case when ifnull(ec.EVENTCALLNATURE_GUID,'')=''   then 0 else 1 end) as workcount  
														from dg_region dr
														left join Eventcallnature ec on  ec.region=dr.regionid
														    and ec.CREATETIME >= DATE_FORMAT(?,'%Y-%m-%d 00:00:00') 
														    and ec.CREATETIME <= DATE_FORMAT(?,'%Y-%m-%d 23:59:59') 
														    ''' + SQLDSL + '''
														left join Callnaturegroup cg on  ec.CALLNATUREGROUP_ID like concat("%",cg.CALLNATUREGROUP_ID,"%") 
														    and cg.type='1'
														    
														where 1=1
                            GROUP BY dr.Regionname 
                            order by dr.OrderNo asc''';
        log.debug("belongareasql:" + belongareasql);




         belongarealist1 = jt.queryForList(belongareasql,startTime,endTime);
        log.debug("常规数据:" + belongarealist1.toString());

        if (eChartProportion == 2) {
            //同比数据
             belongarealist2 = jt.queryForList(belongareasql,compareStartTime,compareEndTime);
            log.debug("同比数据" + belongarealist2.size());
        }



        String[][] DataTable;
        int ListCount = belongarealist1.size();
        //处理Echats图所需数据--初始化数组,分常规和同比
        if (eChartProportion == 2) {
            String[][] DataB = new String[ListCount + 1][4];
            DataB[0][0] = "日期"; //大区
            DataB[0][1] = datedesc; //工单数据
            DataB[0][2] = tb_datedesc;  //同比工单数据
            DataB[0][3] = "增长率";
            double growthRate=0;
            double newValue=0;
            double oldValue=0;

            DecimalFormat df = new DecimalFormat("#.0");
            for (int i = 0; i < belongarealist1.size(); i++) {
                DataB[i + 1][0] = belongarealist1[i].get("Regionname"); //大区
                DataB[i + 1][1] = belongarealist1[i].get("workcount");//工单数据
                DataB[i + 1][2] = belongarealist2[i].get("workcount");//同比工单数据
                newValue = belongarealist2[i].get("workcount");
                oldValue = belongarealist1[i].get("workcount");
                //计算增长率
                if(newValue>0&&oldValue>0){
                    growthRate=df.format((newValue-oldValue)/oldValue*100).toDouble();
                }else{
                    growthRate=0.0;
                }
                DataB[i + 1][3] = growthRate; //对比工单
            }
            DataTable = DataB;
            resObject.put("echatsdata", DataB);
        } else {
            String[][] DataB = new String[ListCount + 1][2];
            DataB[0][0] = "日期"; //大区
            DataB[0][1] = datedesc; //工单数据

            for (int i = 0; i < belongarealist1.size(); i++) {
                DataB[i + 1][0] = belongarealist1[i].get("Regionname"); //大区
                DataB[i + 1][1] = belongarealist1[i].get("workcount");//工单数据
            }
            resObject.put("echatsdata", DataB);
        }

        //数据表
        if (eChartProportion == 2) {
            String[][] DataA = new String[4][ListCount + 1];
            DataA[0][0] = "日期"; //表头
            DataA[1][0] = datedesc; //工单
            DataA[2][0] = tb_datedesc; //对比日期
            DataA[3][0] = "增长率"; //
            for (int i = 0; i < belongarealist1.size(); i++) {
                DataA[0][i + 1] = belongarealist1[i].get("Regionname"); //表头
                DataA[1][i + 1] = belongarealist1[i].get("workcount"); //工单
                DataA[2][i + 1] = belongarealist2[i].get("workcount"); //对比工单
                DataA[3][i + 1] = DataTable[i + 1][3]+"%"; //增长率
            }
            resObject.put("tabledata", DataA);
        } else {
            String[][] DataA = new String[2][ListCount + 1];
            DataA[0][0] = "日期"; //表头
            DataA[1][0] = datedesc; //工单
            for (int i = 0; i < belongarealist1.size(); i++) {
                DataA[0][i + 1] = belongarealist1[i].get("Regionname"); //表头
                DataA[1][i + 1] = belongarealist1[i].get("workcount"); //工单
            }
            resObject.put("tabledata", DataA);
        }
        return resObject;
    }








    /**
     * 客诉工单进度报表
     * @return
     */
    String customerComplaintScheduleReport(EliteBean eliteBean, String startTime, String endTime, int eChartDateType, int quarter, int annual, int year) {
        /*
        eChart图表Json封装
         */
        JSONObject RESULT = new JSONObject();
        JSONObject eChartJson = new JSONObject();//eChart报文
        JSONObject eChartTitleJson = new JSONObject();//图表标题
        String[] color = ["#33CC66", "#3333FF", "#FFCC00"];//图表颜色属性
        JSONObject eChartTooltipJson = new JSONObject();//图表tooltip属性
        JSONObject eChartLegendJson = new JSONObject();//图表legend属性
        JSONArray eChartSeriesArray = new JSONArray();//图表series属性
        JSONObject eChartSeriesJson = new JSONObject();//图表series属性
        JSONObject eChartLabelJson = new JSONObject();//图表series的标签属性
        JSONObject eChartNormalJson = new JSONObject();//图表series的标签的normal属性
        JSONObject eChartEmphasisJson = new JSONObject();//图表series的emphasis属性
        JSONObject eChartItemStyleJson = new JSONObject();//图表series的emphasis的itemStyle属性
        JSONArray array = null; // eChart图表数据
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }

        //获取eChart图表数据
        String sql = "select objectivestatusdescription as name,count(*) as value  from objective o left join sysc_objectivestatus so on o.OBJECTIVESTATUS=so.OBJECTIVESTATUS where o.OBJECTIVESTATUS in ('CLOSE','OPEN') and o.createddate >= '" + startTime + "' and o.createddate <= '" + endTime + "' and o.map_id='M6AP7I' group by OBJECTIVESTATUSDESCRIPTION";
        List list = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (list.size() > 0) {
            array = JSONArray.fromObject(list);


            String[][] DataA = new String[list.size()][2];
            for (int i = 0; i < list.size(); i++) {
                DataA[i][0] = list[i].get("name"); //状态
                DataA[i][1] = list[i].get("value");//数量
            }
            RESULT.put("eChartArr", DataA);
            log.debug('DataA数据'+DataA.toString())
        }
        /*
        拼接eChart图表报文
         */
        //title
        eChartTitleJson.put("text", "投诉工单进度（图表）");
        eChartTitleJson.put("left", "center");
        eChartJson.put("title", eChartTitleJson);
        //color
        eChartJson.put("color", color);
        //tooltip
        eChartTooltipJson.put("trigger", "item");
        eChartJson.put("tooltip", eChartTooltipJson);
        //legend
        eChartLegendJson.put("orient", "vertical");
        eChartLegendJson.put("left", "left");
        //series
        eChartSeriesJson.put("type", "pie");
        eChartSeriesJson.put("radius", "50%");
        eChartNormalJson.put("formatter", "{b}：{d}%");
        eChartLabelJson.put("normal", eChartNormalJson);
        eChartSeriesJson.put("label", eChartLabelJson);
        eChartSeriesJson.put("data", array);
        eChartItemStyleJson.put("shadowBlur", 10);
        eChartItemStyleJson.put("shadowOffsetX", 0);
        eChartItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
        eChartEmphasisJson.put("itemStyle", eChartItemStyleJson);
        eChartSeriesJson.put("emphasis", eChartEmphasisJson);
        eChartSeriesArray.add(eChartSeriesJson);
        eChartJson.put("series", eChartSeriesArray);

        RESULT.put("eChartJson", eChartJson);
        return RESULT.toString();
    }
    /**
     * 客诉总量趋势报表
     * @return
     */
    String customerComplaintTotalTrendReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int year, int compareYear,int quarter,String tb_startTime, String tb_endTime) {
        /*
        eChart图表Json封装
         */

        JSONObject legend = new JSONObject();
        JSONObject axisTick = new JSONObject();
        String[] xData = null; // eChart图表x轴坐标刻度
        String[] yData = null; // eChart图表y轴数据
        String[] yData0 = null; // eChart图表y轴数据
        String[] yData1 = null; // eChart图表y轴数据
        String[] yData2 = null; // eChart图表y轴数据

        StringBuffer sql = new StringBuffer();
        StringBuffer sql1 = new StringBuffer();

        //检查eChartDateType,分为月度、季度、半年、年度
        switch (eChartDateType) {
            case 1:
                if (eChartProportion == 1) {
                    sql.append(
                            '''select t.months AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_months t
                                        LEFT JOIN (
                                        SELECT
                                        DATE_FORMAT( o.createddate, '%Y-%m') AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND DATE_FORMAT(o.createddate, '%Y-%m') >= '''+"'"+startTime+"'"+ '''
                                            AND DATE_FORMAT(o.createddate, '%Y-%m') <= '''+"'"+endTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY DATE_FORMAT( o.createddate, '%Y-%m') 
                                ) t1 ON t.months = t1.date_num
								where  t.months>= '''+"'"+startTime+"'"+ '''
                                        and t.months<= '''+"'"+endTime+"'"+ '''
                                 '''
                    );

                } else {
                    sql.append(
                            '''	select '1' as  datatype,t.months AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_months t
                                        LEFT JOIN (		
												SELECT
													
													DATE_FORMAT( o.createddate, '%Y-%m') AS date_num,
													count( 1 ) AS total 
													FROM
													OBJECTIVE o
													LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
													WHERE
															o.map_id = 'M6AP7I' 
															AND DATE_FORMAT(o.createddate, '%Y-%m') >= '''+"'"+startTime+"'"+ '''
                                                            AND DATE_FORMAT(o.createddate, '%Y-%m') <= '''+"'"+endTime+"'"+ '''
															AND o.objectivestatus != 'FAIL' 
													GROUP BY DATE_FORMAT( o.createddate, '%Y-%m')
                                ) t1 ON t.months = t1.date_num
								 where  t.months>= '''+"'"+startTime+"'"+ '''
                                        and t.months<= '''+"'"+endTime+"'"+ '''
								'''
                    );

                    sql1.append(
                            '''
								select '2' as  datatype,t.months AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_months t
                                        LEFT JOIN (						
												SELECT
													DATE_FORMAT( o.createddate, '%Y-%m') AS date_num,
													count( 1 ) AS total 
													FROM
													OBJECTIVE o
													LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
													WHERE
															o.map_id = 'M6AP7I' 
                                                            AND DATE_FORMAT(o.createddate, '%Y-%m') >= '''+"'"+tb_startTime+"'"+ '''
                                                            AND DATE_FORMAT(o.createddate, '%Y-%m') <= '''+"'"+tb_endTime+"'"+ '''
															AND o.objectivestatus != 'FAIL' 
													GROUP BY DATE_FORMAT( o.createddate, '%Y-%m')
                                ) t1 ON t.months = t1.date_num
								where  t.months>= '''+"'"+tb_startTime+"'"+ '''
                                        and t.months<= '''+"'"+tb_endTime+"'"+ '''
								'''
                    );

                }
                break;
            case 2:
                if (eChartProportion == 1) {
                    sql.append('''select t.quarterdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_quarter t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) >= '''+"'"+startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) <= '''+"'"+endTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) 
                                ) t1 ON t.yearquarter = t1.date_num
								where   t.yearquarter>= '''+"'"+startTime+"'"+ '''
                                        and t.yearquarter<= '''+"'"+endTime+"'"+ ''' 
                                            '''
                    );
                } else {
                    sql.append('''select t.quarterdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_quarter t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) >= '''+"'"+startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) <= '''+"'"+endTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) 
                                ) t1 ON t.yearquarter = t1.date_num
								where   t.yearquarter>= '''+"'"+startTime+"'"+ '''
                                        and t.yearquarter<= '''+"'"+endTime+"'"+ ''' 
                                            '''
                    );

                    sql1.append('''select t.quarterdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_quarter t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) >= '''+"'"+tb_startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) <= '''+"'"+tb_endTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),QUARTER(o.createddate)) 
                                ) t1 ON t.yearquarter = t1.date_num
								where   t.yearquarter>= '''+"'"+tb_startTime+"'"+ '''
                                        and t.yearquarter<= '''+"'"+tb_endTime+"'"+ ''' 
                                            '''
                    );
                }
                break;
            case 3:
                if (eChartProportion == 1) {
                    sql.append('''select t.year_halfdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_half t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) >= '''+"'"+startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) <= '''+"'"+endTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2))
                                ) t1 ON t.year_half = t1.date_num
								where    year_half>= '''+"'"+startTime+"'"+ '''
                                        and  year_half<= '''+"'"+endTime+"'"+ ''' '''
                    );
                } else {
                    sql.append('''select t.year_halfdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_half t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) >= '''+"'"+startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) <= '''+"'"+startTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2))
                                ) t1 ON t.year_half = t1.date_num
								where    year_half>= '''+"'"+startTime+"'"+ '''
                                        and  year_half<= '''+"'"+endTime+"'"+ ''' '''
                    );
                    sql1.append('''select t.year_halfdesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_half t
                                        LEFT JOIN (
                                        SELECT
                                        CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) >= '''+"'"+tb_startTime+"'"+ '''
                                            AND CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2)) <= '''+"'"+tb_startTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY CONCAT(DATE_FORMAT( o.createddate, '%Y'),if(DATE_FORMAT(o.createddate, '%c')<=6,1,2))
                                ) t1 ON t.year_half = t1.date_num
								where    year_half>= '''+"'"+tb_startTime+"'"+ '''
                                        and  year_half<= '''+"'"+tb_endTime+"'"+ ''' '''
                    );

                }
                break;
            case 4:
                if (eChartProportion == 1) {
                    sql.append('''
                                select t.yeardesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_d t
                                        LEFT JOIN (
                                        SELECT
                                        DATE_FORMAT( o.createddate, '%Y') AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND DATE_FORMAT( o.createddate, '%Y') >= '''+"'"+startTime+"'"+ '''
                                            AND DATE_FORMAT( o.createddate, '%Y') <= '''+"'"+startTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY DATE_FORMAT( o.createddate, '%Y')
                                ) t1 ON t.yearid = t1.date_num
								where    yearid>= '''+"'"+startTime+"'"+ '''
                                        and  yearid<= '''+"'"+endTime+"'"+ '''
                                    '''
                    );
                } else {
                    sql.append('''
                                select t.yeardesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_d t
                                        LEFT JOIN (
                                        SELECT
                                        DATE_FORMAT( o.createddate, '%Y') AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND DATE_FORMAT( o.createddate, '%Y') >= '''+"'"+startTime+"'"+ '''
                                            AND DATE_FORMAT( o.createddate, '%Y') <= '''+"'"+startTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY DATE_FORMAT( o.createddate, '%Y')
                                ) t1 ON t.yearid = t1.date_num
								where    yearid>= '''+"'"+startTime+"'"+ '''
                                        and  yearid<= '''+"'"+endTime+"'"+ '''
                                    '''
                    );


                    sql1.append('''
                                select t.yeardesc AS type,
                                          ifnull( t1.total, 0 ) AS total  
                                       from year_d t
                                        LEFT JOIN (
                                        SELECT
                                        DATE_FORMAT( o.createddate, '%Y') AS date_num,
                                        count( 1 ) AS total 
                                        FROM
                                        OBJECTIVE o
                                        LEFT JOIN tabcworkorder tabc ON o.WORKORDERID = tabc.workorderid 
                                        WHERE
                                            o.map_id = 'M6AP7I' 
                                            AND DATE_FORMAT( o.createddate, '%Y') >= '''+"'"+tb_startTime+"'"+ '''
                                            AND DATE_FORMAT( o.createddate, '%Y') <= '''+"'"+tb_startTime+"'"+ '''
                                            AND o.objectivestatus != 'FAIL' 
                                        GROUP BY DATE_FORMAT( o.createddate, '%Y')
                                ) t1 ON t.yearid = t1.date_num
								where    yearid>= '''+"'"+tb_startTime+"'"+ '''
                                        and  yearid<= '''+"'"+tb_endTime+"'"+ '''
                                    '''
                    );
                }
        }






        //处理常规查询echart图表
        if (eChartProportion == 1){
            List datalist = eliteBean.chaxun_sql(sql.toString(), DATA_SOURCE);
            xData = new String[datalist.size()];
            yData = new String[datalist.size()];
            if (datalist.size() > 0) {
                for (int i = 0; i < datalist.size(); i++) {
                    yData[i] = datalist[i].get("total");
                    xData[i] = datalist[i].get("type");
                }
            }

            JSONObject DataAOBJ= new JSONObject();
            DataAOBJ.put("ydata", yData);
            DataAOBJ.put("xdata", xData);
            return DataAOBJ.toString();
        }else
        //处理同比echart图表
        {
            List datalist0 = eliteBean.chaxun_sql(sql.toString(), DATA_SOURCE);
            List datalist1 = eliteBean.chaxun_sql(sql1.toString(), DATA_SOURCE);

            String onedesc = "";
            String twodesc = "";
            String tb_onedesc = "";
            String tb_twodesc = "";

            //处理legend信息
            if(eChartDateType==1){
                //原始数据
                onedesc = getTimeDesc(eliteBean,startTime,eChartDateType);
                twodesc = getTimeDesc(eliteBean,endTime,eChartDateType);
                tb_onedesc = getTimeDesc(eliteBean,tb_startTime,eChartDateType);
                tb_twodesc = getTimeDesc(eliteBean,tb_endTime,eChartDateType);
            }else if(eChartDateType==2){
                //原始数据
                onedesc = getTimeDesc(eliteBean,startTime,eChartDateType);
                twodesc = getTimeDesc(eliteBean,endTime,eChartDateType);
                tb_onedesc = getTimeDesc(eliteBean,tb_startTime,eChartDateType);
                tb_twodesc = getTimeDesc(eliteBean,tb_endTime,eChartDateType);
            }else if(eChartDateType==3){
                //原始数据
                onedesc = getTimeDesc(eliteBean,startTime,eChartDateType);
                twodesc = getTimeDesc(eliteBean,endTime,eChartDateType);
                tb_onedesc = getTimeDesc(eliteBean,tb_startTime,eChartDateType);
                tb_twodesc = getTimeDesc(eliteBean,tb_endTime,eChartDateType);
            }else if(eChartDateType==4){
                //原始数据
                onedesc = getTimeDesc(eliteBean,startTime,eChartDateType);
                twodesc = getTimeDesc(eliteBean,endTime,eChartDateType);
                tb_onedesc = getTimeDesc(eliteBean,tb_startTime,eChartDateType);
                tb_twodesc = getTimeDesc(eliteBean,tb_endTime,eChartDateType);
            }
            String legend1 = onedesc+"~"+twodesc;
            String legend2 = tb_onedesc+"~"+tb_twodesc;

            log.debug('-------------SQL----------------'+sql);
            log.debug('-----------SQL1-------------'+sql1);
            //处理头部数组
            String[] legenddata=new String[3];
            legenddata[0] = legend1;
            legenddata[1] = legend2;
            legenddata[2] = "增长率";
            JSONObject DataAOBJ= new JSONObject();
            DataAOBJ.put("legenddata", legenddata);



            //处理图表数据
            xData = new String[datalist0.size()];
            yData0 = new String[datalist0.size()];
            yData1 = new String[datalist0.size()];
            yData2 = new String[datalist0.size()];
            DecimalFormat df = new DecimalFormat("#.00");

            if (datalist0.size() > 0) {
                for (int i = 0; i < datalist0.size(); i++) {
                    xData[i] = datalist0[i].get("type");
                    yData0[i] = datalist0[i].get("total");
                    yData1[i] = datalist1[i].get("total");

                    //处理增长率数据
                    double A =  datalist0[i].get("total");
                    double B = datalist1[i].get("total");
                    log.debug('计算基础数据:A:'+A+'B:'+B+'计算((A-B)/A)*100：-------');

                    if(A>0&&(A-B)!=0){
                        String C = df.format(((A-B)/A)*100);
                        yData2[i] = C;
                    }else{
                        yData2[i] =0;
                    }

                }
            }

            DataAOBJ.put("xdata", xData); //日期
            DataAOBJ.put("ydata0", yData0); //常规
            DataAOBJ.put("ydata1", yData1); //同比
            DataAOBJ.put("ydata2", yData2); //增长率
            return DataAOBJ.toString();




        }

    }

    /**
     * 满意度回访评价
     * @return
     */
    String customerComplaintSatisfactionReport() {
        return "";
    }

    /**
     * 客诉责任分析
     * @return
     */
    String customerComplaintResponsibilityReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear) {
        JSONObject RESULT = new JSONObject();
        JSONObject eChartJson = new JSONObject();
        JSONObject eChartTitleJson = new JSONObject();
        JSONObject eChartTitleJson1 = new JSONObject();
        JSONArray titleArray = new JSONArray();
        JSONObject eChartTextStyleJson = new JSONObject();
        JSONObject eChartTooltipJson = new JSONObject();
        JSONObject eChartLegendJson = new JSONObject();
        JSONObject eChartSeriesJson = new JSONObject();
        JSONObject eChartSeriesJson1 = new JSONObject();
        JSONObject eChartSeriesLabelJson = new JSONObject();
        JSONObject eChartSeriesLabelNormalJson = new JSONObject();
        JSONObject eChartSeriesEmphasisJson = new JSONObject();
        JSONObject eChartSeriesEmphasisItemStyleJson = new JSONObject();
        JSONArray eChartSeriesArray = new JSONArray();
        JSONObject gridJson = new JSONObject();
        String[] color = ["#0066CC", "#66CC99", "#CCCCCC", "#FF6666", "#00CCFF"];
        String[] centerOne = ["25%", "50%"]; //位置
        String[] centerTwo = ["75%", "50%"]; //位置
        JSONArray array = null;
        JSONArray array1 = null;
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }

        String sql ="SELECT " +
                "c.code_name as name," +
                " count(*) as value" +
                " FROM" +
                " objective o" +
                " LEFT JOIN tabcworkorder t ON o.objective_guid = t.relation_id" +
                " LEFT JOIN c_codetables c ON t.dutyReason = c.code_id " +
                " AND c.use_type = 'responsibility' " +
                "WHERE" +
                " o.map_id = 'M6AP7I' " +
                " AND o.objectivestatus != 'FAIL' " +
                " AND o.createddate >= '"+ startTime + "' " +
                " AND o.createddate <= '"+ endTime + "' " +
                " AND t.dutyReason != '' " +
                " AND t.dutyReason IS NOT NULL " +
                "GROUP BY" +
                " c.Code_Name";
        List list = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (list.size() > 0) {
            array = JSONArray.fromObject(list);

            String[][] DataA = new String[list.size()][2];
            for (int i = 0; i < list.size(); i++) {
                DataA[i][0] = list[i].get("name"); //责任类型
                DataA[i][1] = list[i].get("value");//数量
            }
            RESULT.put("eChartArr", DataA);
            log.debug('DataA数据'+DataA.toString())

        }

        String sql1 ="SELECT " +
                "c.code_name as name," +
                " count(*) as value" +
                " FROM" +
                " objective o" +
                " LEFT JOIN tabcworkorder t ON o.objective_guid = t.relation_id" +
                " LEFT JOIN c_codetables c ON t.dutyReason = c.code_id " +
                " AND c.use_type = 'responsibility' " +
                "WHERE" +
                " o.map_id = 'M6AP7I' " +
                " AND o.objectivestatus != 'FAIL' " +
                " AND o.createddate >= '"+ compareStartTime + "' " +
                " AND o.createddate <= '"+ compareEndTime + "' " +
                " AND t.dutyReason != '' " +
                " AND t.dutyReason IS NOT NULL " +
                "GROUP BY" +
                " c.Code_Name";
        List list1 = eliteBean.chaxun_sql(sql1, DATA_SOURCE);

        if (list1.size() > 0) {
            array1 = JSONArray.fromObject(list1);

            String[][] DataB = new String[list.size()][2];
            for (int i = 0; i < list1.size(); i++) {
                DataB[i][0] = list1[i].get("name"); //责任类型
                DataB[i][1] = list1[i].get("value");//数量
            }
            RESULT.put("eChartArr1", DataB);
            log.debug('DataA数据B'+DataB.toString())
        }

        try {
            if (eChartProportion == 1) {
                //title
                eChartTitleJson.put("text", currentDate);
                eChartTitleJson.put("left", "center");
                eChartTextStyleJson.put("color", "Orange");
                eChartTextStyleJson.put("fontSize", 18);
                eChartTextStyleJson.put("fontWeight", "bold");
                eChartTitleJson.put("textStyle", eChartTextStyleJson);
                eChartJson.put("title", eChartTitleJson);
                //tooltip
                eChartTooltipJson.put("trigger", "item");
                eChartJson.put("tooltip", eChartTooltipJson);
                gridJson.put("left", "1%");
                gridJson.put("right", "1%");
                gridJson.put("top", "1%");
                gridJson.put("bottom", "1%");
                gridJson.put("containLabel", true);
                eChartJson.put("grid", gridJson);
                //color
                eChartJson.put("color", color);
                //legend
                eChartLegendJson.put("orient", "vertical");
                eChartLegendJson.put("left", "left");
                eChartJson.put("legend", eChartLegendJson);
                //series
                eChartSeriesJson.put("type", "pie");
                eChartSeriesJson.put("radius", "50%");
                //series label normal
                eChartSeriesLabelNormalJson.put("formatter", "{b}：{d}%");
                //series label
                eChartSeriesLabelJson.put("normal", eChartSeriesLabelNormalJson);
                eChartSeriesJson.put("label", eChartSeriesLabelJson);
                eChartSeriesJson.put("data", array);
                //series emphasis itemStyle
                eChartSeriesEmphasisItemStyleJson.put("shadowBlur", 10);
                eChartSeriesEmphasisItemStyleJson.put("shadowOffsetX", 0);
                eChartSeriesEmphasisItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
                eChartSeriesEmphasisJson.put("itemStyle", eChartSeriesEmphasisItemStyleJson);
                //series emphasis
                eChartSeriesJson.put("emphasis", eChartSeriesEmphasisJson);
                eChartSeriesArray.add(eChartSeriesJson);
            } else {
                //title titleArray
                eChartTitleJson.put("text", currentDate);
                eChartTitleJson.put("left", "25%");
                eChartTextStyleJson.put("color", "Orange");
                eChartTextStyleJson.put("fontSize", 18);
                eChartTextStyleJson.put("fontWeight", "bold");
                eChartTitleJson.put("textStyle", eChartTextStyleJson);
                titleArray.add(eChartTitleJson);

                eChartTitleJson1.put("text", compareDate);
                eChartTitleJson1.put("left", "75%");
                eChartTitleJson1.put("textStyle", eChartTextStyleJson);
                titleArray.add(eChartTitleJson1);
                eChartJson.put("title", titleArray);
                //tooltip
                eChartTooltipJson.put("trigger", "item");
                eChartJson.put("tooltip", eChartTooltipJson);
                gridJson.put("left", "1%");
                gridJson.put("right", "1%");
                gridJson.put("top", "1%");
                gridJson.put("bottom", "1%");
                gridJson.put("containLabel", true);
                eChartJson.put("grid", gridJson);
                //color
                eChartJson.put("color", color);
                //legend
                eChartLegendJson.put("orient", "vertical");
                eChartLegendJson.put("left", "left");
                eChartJson.put("legend", eChartLegendJson);
                //series
                eChartSeriesJson.put("type", "pie");
                eChartSeriesJson.put("radius", "50%");
                //series label normal
                eChartSeriesLabelNormalJson.put("formatter", "{b}：{d}%");
                //series label
                eChartSeriesLabelJson.put("normal", eChartSeriesLabelNormalJson);
                eChartSeriesJson.put("label", eChartSeriesLabelJson);
                eChartSeriesJson.put("data", array);
                eChartSeriesJson.put("center", centerOne);
                //series emphasis itemStyle
                eChartSeriesEmphasisItemStyleJson.put("shadowBlur", 10);
                eChartSeriesEmphasisItemStyleJson.put("shadowOffsetX", 0);
                eChartSeriesEmphasisItemStyleJson.put("shadowColor", "rgba(0, 0, 0, 0.5)");
                eChartSeriesEmphasisJson.put("itemStyle", eChartSeriesEmphasisItemStyleJson);
                //series emphasis
                eChartSeriesJson.put("emphasis", eChartSeriesEmphasisJson);
                eChartSeriesArray.add(eChartSeriesJson);
                eChartSeriesJson1.put("type", "pie");
                eChartSeriesJson1.put("radius", "50%");
                eChartSeriesJson1.put("label", eChartSeriesLabelJson);
                eChartSeriesJson1.put("data", array1);
                eChartSeriesJson1.put("center", centerTwo);
                //series emphasis
                eChartSeriesJson1.put("emphasis", eChartSeriesEmphasisJson);
                eChartSeriesArray.add(eChartSeriesJson1);
            }
        } catch (Exception e3) {
            log.error("第二段sql处理异常：" + e3.getMessage());
        }


        eChartJson.put("series", eChartSeriesArray);
        RESULT.put("eChartJson", eChartJson);


        return RESULT.toString();

    }

    /**
     * 话务数据报表
     * @return
     */
    String callDetailReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, String currentDate, String compareDate, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int month, int year, int compareYear) {
        JSONArray array = null;
        JSONArray arrayCompare = null;
        JSONObject eChartJson = new JSONObject();//echart图表数据
        JSONObject titleJson = new JSONObject();
        JSONObject tooltipJson = new JSONObject();
        JSONObject axisPointerJson = new JSONObject();
        JSONObject gridJson = new JSONObject();
        JSONObject legendJson = new JSONObject();
        JSONArray xAxisArray = new JSONArray();
        JSONObject xAxisJson = new JSONObject();
        JSONObject axisTickJson = new JSONObject();
        JSONArray yAxisArray = new JSONArray();
        JSONObject yAxisJson = new JSONObject();
        JSONArray seriesArray = new JSONArray();
        JSONObject seriesJson = new JSONObject();
        JSONObject seriesCompareJson = new JSONObject();
        JSONObject labelJson = new JSONObject();
        JSONObject normalJson = new JSONObject();
        JSONObject textStyleJson = new JSONObject();
        String[] color = ["#006699", "#66CC66"];
        int zmd = 0;//专卖店及开店
        int sale = 0; // 销售咨询
        int skill = 0; // 技术咨询
        int complaint = 0;// 投诉与建议
        int zmdCompare = 0;//专卖店及开店
        int saleCompare = 0; // 销售咨询
        int skillCompare = 0; // 技术咨询
        int complaintCompare = 0;// 投诉与建议
        int[] yData = new int[4];
        int[] yDataCompare = new int[4];
        String[] xData = ["专卖店及开店", "销售咨询", "技术咨询", "投诉与建议"];
        String[] legendData = [currentDate, compareDate];
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        } else if (eChartProportion == 3) {
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, year, month);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear, month);
            if (eChartDateType == 1) {
                DateFormat dft = new SimpleDateFormat("yyyy-MM-dd");
                Date star = dft.parse(startTime);
                Date endDay = dft.parse(compareStartTime);
                SimpleDateFormat sf = new SimpleDateFormat("yyyy年MM月");
                currentDate = sf.format(star);
                compareDate = sf.format(endDay);
            } else if (eChartDateType == 2) {
                switch (quarter) {
                    case 1:
                        currentDate = year + "第一季度";
                        compareDate = (year - 1) + "第四季度";
                        break;
                    case 2:
                        currentDate = year + "第二季度";
                        compareDate = year + "第一季度";
                        break;
                    case 3:
                        currentDate = year + "第三季度";
                        compareDate = year + "第二季度";
                        break;
                    case 4:
                        currentDate = year + "第四季度";
                        compareDate = year + "第三季度";
                        break;
                }
            } else if (eChartDateType == 3) {
                switch (quarter) {
                    case 1:
                        currentDate = year + "上半年";
                        compareDate = (year - 1) + "下半年";
                        break;
                    case 2:
                        currentDate = year + "下半年";
                        compareDate = year + "上半年";
                        break;

                }
            } else if (eChartDateType == 4) {
                currentDate = year + "年";
                compareDate = (year - 1) + "年";
            }
            legendData[0] = currentDate;
            legendData[1] = compareDate;
        }
        String sql = '''SELECT
                            qname as name,
                            count(1) as value
                        FROM
                            clink_list_cdr_ibs 
                        WHERE
                            FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + startTime + '''\' 
                            AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + endTime + '''\'
                            and qname <> ''
                        GROUP BY
                            qname''';
        List list = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (list.size() > 0) {
            array = JSONArray.fromObject(list);
            for (int i = 0; i < array.size(); i++) {
                JSONObject jsonObject = array.get(i);
                if (jsonObject.getString("name").contains("专卖店及开店")) {
                    zmd = zmd + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("销售咨询")) {
                    sale = sale + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("技术咨询")) {
                    skill = skill + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("投诉与建议")) {
                    complaint = complaint + jsonObject.getInt("value");
                }
            }
            yData[0] = zmd;
            yData[1] = sale;
            yData[2] = skill;
            yData[3] = complaint;

        }
        String sqlCompare = '''SELECT
                                qname as name,
                                count(1) as value
                            FROM
                                clink_list_cdr_ibs 
                            WHERE
                                FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + compareStartTime + '''\' 
                                AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + compareEndTime + '''\'
                                and qname <> ''
                            GROUP BY
                                qname''';
        List listCompare = eliteBean.chaxun_sql(sqlCompare, DATA_SOURCE);
        if (listCompare.size() > 0) {
            arrayCompare = JSONArray.fromObject(listCompare);
            for (int i = 0; i < arrayCompare.size(); i++) {
                JSONObject jsonObject = arrayCompare.get(i);
                if (jsonObject.getString("name").contains("专卖店及开店")) {
                    zmdCompare = zmdCompare + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("销售咨询")) {
                    saleCompare = saleCompare + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("技术咨询")) {
                    skillCompare = skillCompare + jsonObject.getInt("value");
                }
                if (jsonObject.getString("name").contains("投诉与建议")) {
                    complaintCompare = complaintCompare + jsonObject.getInt("value");
                }
            }
            yDataCompare[0] = zmdCompare;
            yDataCompare[1] = saleCompare;
            yDataCompare[2] = skillCompare;
            yDataCompare[3] = complaintCompare;
        }

        //拼接eChart数据报文
        titleJson.put("text", "话务数据（图表）");
        titleJson.put("left", "center");
        eChartJson.put("title", titleJson);
        eChartJson.put("color", color);
        tooltipJson.put("trigger", "axis");
        axisPointerJson.put("type", "shadow");
        tooltipJson.put("axisPointer", axisPointerJson);
        eChartJson.put("tooltip", tooltipJson);
        gridJson.put("left", "1%");
        gridJson.put("right", "1%");
        gridJson.put("bottom", "1%");
        gridJson.put("containLabel", true);
        eChartJson.put("grid", gridJson);
        if (eChartProportion != 1) {
            legendJson.put("data", legendData);
            legendJson.put("left", 10);
            eChartJson.put("legend", legendJson);
        }
        xAxisJson.put("type", "category");
        xAxisJson.put("data", xData);
        axisTickJson.put("alignWithLabel", true);
        xAxisJson.put("axisTick", axisTickJson);
        xAxisArray.add(xAxisJson);
        eChartJson.put("xAxis", xAxisArray);
        yAxisJson.put("type", "value");
        yAxisArray.add(yAxisJson);
        eChartJson.put("yAxis", yAxisArray);
        seriesJson.put("name", currentDate);
        seriesJson.put("type", "bar");
        seriesJson.put("barWidth", "10%");
        seriesJson.put("data", yData);
        normalJson.put("show", true);
        normalJson.put("position", "top");
        textStyleJson.put("color", "black");
        textStyleJson.put("fontSize", 14);
        textStyleJson.put("fontWeight", "bold");
        normalJson.put("textStyle", textStyleJson);
        labelJson.put("normal", normalJson);
        seriesJson.put("label", labelJson);
        seriesArray.add(seriesJson);
        if (eChartProportion != 1) {
            seriesCompareJson.put("name", compareDate);
            seriesCompareJson.put("type", "bar");
            seriesCompareJson.put("barWidth", "10%");
            seriesCompareJson.put("data", yDataCompare);
            seriesCompareJson.put("label", labelJson);
            seriesArray.add(seriesCompareJson);
        }
        eChartJson.put("series", seriesArray);

        return eChartJson.toString();
    }
    /**
     * 话务表格数据
     * @return
     */
    String callDetailTable(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int month, int year, int compareYear) {
        String[][] arr = null;//二维数组
        JSONObject resultJson = new JSONObject();
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        } else if (eChartProportion == 3) {
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear, month);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear, month);
        }
        StringBuffer sql = new StringBuffer();
        if (eChartDateType == 1) {
            sql.append('''SELECT
                       FROM_UNIXTIME(startTime,'%Y-%m-%d') as date,
                       sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                       sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                       sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                       sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                     FROM
                       clink_list_cdr_ibs 
                     WHERE
                       FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + startTime + '''\'
                       AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + endTime + '''\'
                       and qname <> ''
                     group by 
                       FROM_UNIXTIME(startTime,'%Y-%m-%d')
            ''');
        } else if (eChartDateType == 2) {
            sql.append('''SELECT
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '03-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','一季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '04-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','二季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '09-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','三季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '10-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','四季度') end as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + startTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + endTime + '''\'
                        and qname <> ''
                        group by 
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '03-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','一季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '04-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','二季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '09-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','三季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '10-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','四季度') end
            ''');
        } else if (eChartDateType == 3) {
            sql.append('''SELECT
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'上','半年')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'下','半年') end as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + startTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + endTime + '''\'
                        and qname <> ''
                        group by 
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'上','半年')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'下','半年') end
            ''');
        } else if (eChartDateType == 4) {
            sql.append('''SELECT
                        concat(FROM_UNIXTIME(startTime,'%Y'),'','年') as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + startTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + endTime + '''\'
                        and qname <> ''
                        group by 
                        concat(FROM_UNIXTIME(startTime,'%Y'),'','年')
            ''');
        }
        if (eChartProportion != 1) {
            if (eChartDateType == 1) {
                sql.append('''UNION ALL SELECT
                       FROM_UNIXTIME(startTime,'%Y-%m-%d') as date,
                       sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                       sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                       sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                       sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                     FROM
                       clink_list_cdr_ibs 
                     WHERE
                       FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + compareStartTime + '''\'
                       AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + compareEndTime + '''\'
                       and qname <> ''
                     group by 
                       FROM_UNIXTIME(startTime,'%Y-%m-%d')
            ''');
            } else if (eChartDateType == 2) {
                sql.append('''UNION ALL SELECT
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '03-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','一季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '04-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','二季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '09-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','三季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '10-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','四季度') end as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + compareStartTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + compareEndTime + '''\'
                        and qname <> ''
                        group by 
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '03-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','一季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '04-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','二季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '09-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','三季度')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '10-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'第','四季度') end
            ''');
            } else if (eChartDateType == 3) {
                sql.append('''UNION ALL SELECT
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'上','半年')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'下','半年') end as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + compareStartTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + compareEndTime + '''\'
                        and qname <> ''
                        group by 
                        case when FROM_UNIXTIME(startTime,'%m-%d') >= '01-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '06-30' then concat(FROM_UNIXTIME(startTime,'%Y'),'上','半年')
                        when FROM_UNIXTIME(startTime,'%m-%d') >= '07-01' 
                        and FROM_UNIXTIME(startTime,'%m-%d') <= '12-31' then concat(FROM_UNIXTIME(startTime,'%Y'),'下','半年') end
            ''');
            } else if (eChartDateType == 4) {
                sql.append('''UNION ALL SELECT
                        concat(FROM_UNIXTIME(startTime,'%Y'),'','年') as date,
                        sum(case when qname like '%专卖店及开店%' then 1 else 0 end) as 'ZMDJKD',
                        sum(case when qname like '%投诉与建议%' then 1 else 0 end) as 'TSYJY',
                        sum(case when qname like '%销售咨询%' then 1 else 0 end) as 'XSZX',
                        sum(case when qname like '%技术咨询%' then 1 else 0 end) as 'JSZX'
                        FROM
                        clink_list_cdr_ibs 
                        WHERE
                        FROM_UNIXTIME( startTime, '%Y-%m-%d' ) >= \'''' + compareStartTime + '''\' 
                        AND FROM_UNIXTIME( startTime, '%Y-%m-%d' ) <= \'''' + compareEndTime + '''\'
                        and qname <> ''
                        group by 
                        concat(FROM_UNIXTIME(startTime,'%Y'),'','年')
            ''');
            }
        }
        List list = eliteBean.chaxun_sql(sql.toString(), DATA_SOURCE);
        if (list.size() > 0) {
            arr = new String[list.size()][5];
            JSONArray array = JSONArray.fromObject(list);
            for (int i = 0; i < array.size(); i++) {
                JSONObject jsonObject = array.get(i);
                arr[i][0] = jsonObject.getString("date");
                arr[i][1] = jsonObject.getString("ZMDJKD");
                arr[i][2] = jsonObject.getString("TSYJY");
                arr[i][3] = jsonObject.getString("XSZX");
                arr[i][4] = jsonObject.getString("JSZX");
            }
        }
        resultJson.put("data", arr);
        return resultJson.toString();
    }
    /**
     * 客户咨询类型分析表格数据
     * @return
     */
    String customerConsultTable(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear,String sqltype,String skill) {
        String[][] arr = null;//二维数组
        JSONObject resultJson = new JSONObject();
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }

        //工单数据查询
        String whereSql1="";
        if(!KHUtil.isNull(skill)){
            whereSql1=" and o.createdby in ("+skill+")";
        }
        //小结数据查询
        String whereSql2="";
        if(!KHUtil.isNull(skill)){
            whereSql2=" and ec.Createdby in ("+skill+")";
        }


        StringBuffer sql = new StringBuffer();
        if(sqltype.equals("1")){
            //查询数据
            sql.append('''SELECT
                            w1.workordertype1desc as name,
                            count(tabc.workorderid) as value 
                            FROM
                                objective o
                            LEFT JOIN 
                                tabcworkorder tabc ON o.objective_guid = tabc.relation_id
                            LEFT JOIN 
                                sys_workordertype1 w1 ON tabc.workordertype1 = w1.workordertype1_id
                            where 
                                tabc.workordertype1 is not null 
                                and o.objectivestatus!='FAIL'
                                and w1.USEFLAG='1'
                                and o.createddate >= \'''' + startTime + '''\' and o.createddate <= \'''' + endTime + '''\'  ''' + whereSql1 + '''
                            GROUP BY
                            w1.workordertype1desc
                            ''');
            if (eChartProportion == 2) {
                sql.append(''' union all SELECT
                            w1.workordertype1desc as name,
                            count(tabc.workorderid) as value 
                            FROM
                                objective o
                            LEFT JOIN 
                                tabcworkorder tabc ON o.objective_guid = tabc.relation_id
                            LEFT JOIN 
                                sys_workordertype1 w1 ON tabc.workordertype1 = w1.workordertype1_id
                            where 
                                tabc.workordertype1 is not null 
                                and o.objectivestatus!='FAIL'
                                and w1.USEFLAG='1'
                                and o.createddate >= \'''' + compareStartTime + '''\' and o.createddate <= \'''' + compareEndTime + '''\'   ''' + whereSql1 + '''
                            GROUP BY
                            w1.workordertype1desc
                            ''');
            }


        }else{

            //查询数据
            sql.append('''select cg.CALLNATUREGROUPDESCRIPTION as name,
                            sum(case when ifnull(ec.EVENTCALLNATURE_GUID,'')='' then 0 else 1 end) as value  
														from Callnaturegroup cg 
														left join Eventcallnature ec on  ec.CALLNATUREGROUP_ID like concat("%",cg.CALLNATUREGROUP_ID,"%")
														where 1=1
														and cg.type='1'
                                and ec.CREATETIME >= \'''' + startTime + '''\' and ec.CREATETIME <= \'''' + endTime + '''\'  ''' + whereSql2 + '''
                            GROUP BY cg.CALLNATUREGROUPDESCRIPTION''');
            if (eChartProportion == 2) {
                sql.append(''' union all select cg.CALLNATUREGROUPDESCRIPTION as name,
                            sum(case when ifnull(ec.EVENTCALLNATURE_GUID,'')='' then 0 else 1 end) as value  
														from Callnaturegroup cg 
														left join Eventcallnature ec on  ec.CALLNATUREGROUP_ID like concat("%",cg.CALLNATUREGROUP_ID,"%")
														where 1=1
														and cg.type='1'
                                and ec.CREATETIME >= \'''' + compareStartTime + '''\' and ec.CREATETIME <= \'''' + compareEndTime + '''\'  ''' + whereSql2 + '''
                            GROUP BY cg.CALLNATUREGROUPDESCRIPTION 
                            ''');
            }

        }
        List list = eliteBean.chaxun_sql(sql.toString(), DATA_SOURCE);
        if (list.size() > 0) {
            arr = new String[list.size()][2];
            JSONArray customerConsultArray = JSONArray.fromObject(list);
            for (int i = 0; i < customerConsultArray.size(); i++) {
                JSONObject jsonObject = customerConsultArray.get(i);
                arr[i][0] = jsonObject.getString("name");
                arr[i][1] = jsonObject.getString("value");
            }
        }
        resultJson.put("data", arr);
        return resultJson.toString();
    }


    /**
     * 客诉产品品类分析表格数据
     * @return
     */
    String customerComplaintProductCategoryTable(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear) {
        String[][] arr = null;//二维数组
        JSONObject resultJson = new JSONObject();
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }
        StringBuffer sql = new StringBuffer();
        if (eChartDateType == 1) {
            sql.append('''select
                            DATE_FORMAT(tabc.createddate, '%Y-%m') as 'date',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                            GROUP BY
                            DATE_FORMAT(tabc.createddate,'%Y-%m')''');
        } else if (eChartDateType == 2) {
            sql.append('''select
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '03-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','一季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '04-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','二季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '09-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','三季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '10-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','四季度') end as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                            GROUP BY
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '03-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','一季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '04-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','二季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '09-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','三季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '10-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','四季度') end ''');
        } else if (eChartDateType == 3) {
            sql.append('''select
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                            GROUP BY
                             case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end''');
        } else if (eChartDateType == 4) {
            sql.append('''select
                            DATE_FORMAT(tabc.createddate,'%Y')  as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + startTime + '''\' and tabc.createddate <= \'''' + endTime + '''\'
                            GROUP BY
                             case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end''');
        }
        if (eChartDateType == 1 && eChartProportion == 2) {
            sql.append('''UNION ALL select
                            DATE_FORMAT(tabc.createddate, '%Y-%m') as 'date',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                            GROUP BY
                            DATE_FORMAT(tabc.createddate,'%Y-%m')''');
        } else if (eChartDateType == 2 && eChartProportion == 2) {
            sql.append('''UNION ALL select
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '03-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','一季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '04-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','二季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '09-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','三季度')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '10-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','四季度') end as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                            GROUP BY
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '03-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','一季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '04-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','二季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '09-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','三季度')
                            when DATE_FORMAT(tabc.createddate,'%m-%d') >= '10-01' 
                            and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'第','四季度') end ''');
        } else if (eChartDateType == 3 && eChartProportion == 2) {
            sql.append('''UNION ALL select
                            case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                            GROUP BY
                             case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end''');
        } else if (eChartDateType == 4 && eChartProportion == 2) {
            sql.append('''UNION ALL select
                            DATE_FORMAT(tabc.createddate,'%Y')  as date,
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2003' THEN 1 ELSE 0 END) AS 'XKFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = 'XK009' THEN 1 ELSE 0 END) AS 'XKXKJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2006' THEN 1 ELSE 0 END) AS 'XKNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2005' THEN 1 ELSE 0 END) AS 'XKMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2001' THEN 1 ELSE 0 END) AS 'XKCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2207' THEN 1 ELSE 0 END) AS 'XKJSSJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '18' THEN 1 ELSE 0 END) AS 'XKGJPT',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2007' THEN 1 ELSE 0 END) AS 'XKQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2004' THEN 1 ELSE 0 END) AS 'XKTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0002' AND tabc.product_type = '2008' THEN 1 ELSE 0 END) AS 'XKQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '03' THEN 1 ELSE 0 END) AS 'DGFSDL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '06' THEN 1 ELSE 0 END) AS 'DGNZ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '02' THEN 1 ELSE 0 END) AS 'DGBJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '05' THEN 1 ELSE 0 END) AS 'DGMCJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '01' THEN 1 ELSE 0 END) AS 'DGCZJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '10' THEN 1 ELSE 0 END) AS 'DGMFJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '04' THEN 1 ELSE 0 END) AS 'DGQG',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '07' THEN 1 ELSE 0 END) AS 'DGTFL',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '12' THEN 1 ELSE 0 END) AS 
                            'DGQT',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1102' THEN 1 ELSE 0 END) AS 'QJPJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1103' THEN 1 ELSE 0 END) AS 'QJHC',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1101' THEN 1 ELSE 0 END) AS 'QJGJ',
                            sum(CASE WHEN tabc.product_brand = 'PB0001' AND tabc.product_type = '1104' THEN 1 ELSE 0 END) AS 
                            'QJQT'
                            FROM
                            tabcworkorder tabc
                            where 1=1
                            and tabc.createddate >= \'''' + compareStartTime + '''\' and tabc.createddate <= \'''' + compareEndTime + '''\'
                            GROUP BY
                             case when DATE_FORMAT(tabc.createddate,'%m-%d') >= '01-01' 
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '06-30' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'上','半年')
                                when DATE_FORMAT(tabc.createddate,'%m-%d') >= '07-01'  
                                and DATE_FORMAT(tabc.createddate,'%m-%d') <= '12-31' then concat(DATE_FORMAT(tabc.createddate,'%Y'),'下','半年') end''');
        }
        List list = eliteBean.chaxun_sql(sql.toString(), DATA_SOURCE);
        if (list.size() > 0) {
            JSONArray array = JSONArray.fromObject(list);
            arr = new String[list.size()][24];
            for (int i = 0; i < array.size(); i++) {
                JSONObject jsonObject = array.get(i);
                arr[i][0] = jsonObject.getString("date");
                arr[i][1] = jsonObject.getString("XKFSDL");
                arr[i][2] = jsonObject.getString("XKXKJ");
                arr[i][3] = jsonObject.getString("XKNZ");
                arr[i][4] = jsonObject.getString("XKMFJ");
                arr[i][5] = jsonObject.getString("XKCZJ");
                arr[i][6] = jsonObject.getString("XKJSSJ");
                arr[i][7] = jsonObject.getString("XKGJPT");
                arr[i][8] = jsonObject.getString("XKQG");
                arr[i][9] = jsonObject.getString("XKTFL");
                arr[i][10] = jsonObject.getString("XKQT");
                arr[i][11] = jsonObject.getString("DGFSDL");
                arr[i][12] = jsonObject.getString("DGNZ");
                arr[i][13] = jsonObject.getString("DGBJ");
                arr[i][14] = jsonObject.getString("DGMCJ");
                arr[i][15] = jsonObject.getString("DGCZJ");
                arr[i][16] = jsonObject.getString("DGMFJ");
                arr[i][17] = jsonObject.getString("DGQG");
                arr[i][18] = jsonObject.getString("DGTFL");
                arr[i][19] = jsonObject.getString("DGQT");
                arr[i][20] = jsonObject.getString("QJPJ");
                arr[i][21] = jsonObject.getString("QJHC");
                arr[i][22] = jsonObject.getString("QJGJ");
                arr[i][23] = jsonObject.getString("QJQT");
            }
        }
        resultJson.put("data", arr);
        return resultJson.toString();
    }

    /**
     * 满意度回访评价Echart数据
     * @return
     */
    Map satisfactionEvaluateReport(EliteBean eliteBean, String startTime, String endTime, int eChartProportion, String compareStartTime, String compareEndTime, int eChartDateType, int quarter, int annual, int compareQuarter, int compareAnnual, int year, int compareYear) {
        Map resultMap = new HashMap();
        JSONObject eChartJson = new JSONObject();
        JSONObject eChartJson2 = new JSONObject();
        JSONObject eChartJson3 = new JSONObject();
        JSONObject eChartJson4 = new JSONObject();
        JSONObject eChartJson5 = new JSONObject();
        JSONObject eChartJson6 = new JSONObject();
        JSONObject titleJson = new JSONObject();
        JSONObject titleJson2 = new JSONObject();
        JSONObject titleJson3 = new JSONObject();
        JSONObject graphicJson = new JSONObject();
        JSONObject graphicJson2 = new JSONObject();
        JSONObject graphicJson3 = new JSONObject();
        JSONObject graphicJson4 = new JSONObject();
        JSONObject graphicJson5 = new JSONObject();
        JSONObject graphicJson6 = new JSONObject();
        JSONObject styleJson = new JSONObject();
        JSONObject styleJson2 = new JSONObject();
        JSONObject styleJson3 = new JSONObject();
        JSONObject styleJson4 = new JSONObject();
        JSONObject styleJson5 = new JSONObject();
        JSONObject styleJson6 = new JSONObject();
        JSONObject tooltipJson = new JSONObject();
        JSONObject seriesJson = new JSONObject();
        JSONObject seriesJson2 = new JSONObject();
        JSONObject seriesJson3 = new JSONObject();
        JSONObject seriesJson4 = new JSONObject();
        JSONObject seriesJson5 = new JSONObject();
        JSONObject seriesJson6 = new JSONObject();
        JSONObject labelJson = new JSONObject();
        JSONObject labelLineJson = new JSONObject();
        JSONArray seriesArray = new JSONArray();
        JSONArray seriesArray2 = new JSONArray();
        JSONArray seriesArray3 = new JSONArray();
        JSONArray seriesArray4 = new JSONArray();
        JSONArray seriesArray5 = new JSONArray();
        JSONArray seriesArray6 = new JSONArray();
        JSONArray mydArray = new JSONArray();
        JSONArray mydArray1 = new JSONArray();
        JSONArray mydArray2 = new JSONArray();
        JSONObject fcmyJson = new JSONObject();
        JSONObject myJson = new JSONObject();
        JSONObject bmyJson = new JSONObject();
        JSONObject fcmyJson1 = new JSONObject();
        JSONObject myJson1 = new JSONObject();
        JSONObject bmyJson1 = new JSONObject();
        JSONObject fcmyJson2 = new JSONObject();
        JSONObject myJson2 = new JSONObject();
        JSONObject bmyJson2 = new JSONObject();

        JSONObject itemStyleJson = new JSONObject();
        JSONObject normalJson = new JSONObject();
        JSONObject itemStyleJson1 = new JSONObject();
        JSONObject normalJson1 = new JSONObject();
        JSONObject itemStyleJson2 = new JSONObject();
        JSONObject normalJson2 = new JSONObject();

        JSONObject itemStyleJson3 = new JSONObject();
        JSONObject normalJson3 = new JSONObject();
        JSONObject itemStyleJson4 = new JSONObject();
        JSONObject normalJson4 = new JSONObject();
        JSONObject itemStyleJson5 = new JSONObject();
        JSONObject normalJson5 = new JSONObject();

        JSONObject itemStyleJson6 = new JSONObject();
        JSONObject normalJson6 = new JSONObject();
        JSONObject itemStyleJson7 = new JSONObject();
        JSONObject normalJson7 = new JSONObject();
        JSONObject itemStyleJson8 = new JSONObject();
        JSONObject normalJson8 = new JSONObject();

        //同比
        JSONArray mydArrayCompare = new JSONArray();
        JSONArray mydArrayCompare1 = new JSONArray();
        JSONArray mydArrayCompare2 = new JSONArray();
        JSONObject fcmyJsonCompare = new JSONObject();
        JSONObject myJsonCompare = new JSONObject();
        JSONObject bmyJsonCompare = new JSONObject();
        JSONObject fcmyJsonCompare1 = new JSONObject();
        JSONObject myJsonCompare1 = new JSONObject();
        JSONObject bmyJsonCompare1 = new JSONObject();
        JSONObject fcmyJsonCompare2 = new JSONObject();
        JSONObject myJsonCompare2 = new JSONObject();
        JSONObject bmyJsonCompare2 = new JSONObject();

        JSONObject itemStyleJsonCompare = new JSONObject();
        JSONObject normalJsonCompare = new JSONObject();
        JSONObject itemStyleJson1Compare = new JSONObject();
        JSONObject normalJson1Compare = new JSONObject();
        JSONObject itemStyleJson2Compare = new JSONObject();
        JSONObject normalJson2Compare = new JSONObject();

        JSONObject itemStyleJson3Compare = new JSONObject();
        JSONObject normalJson3Compare = new JSONObject();
        JSONObject itemStyleJson4Compare = new JSONObject();
        JSONObject normalJson4Compare = new JSONObject();
        JSONObject itemStyleJson5Compare = new JSONObject();
        JSONObject normalJson5Compare = new JSONObject();

        JSONObject itemStyleJson6Compare = new JSONObject();
        JSONObject normalJson6Compare = new JSONObject();
        JSONObject itemStyleJson7Compare = new JSONObject();
        JSONObject normalJson7Compare = new JSONObject();
        JSONObject itemStyleJson8Compare = new JSONObject();
        JSONObject normalJson8Compare = new JSONObject();
        JSONObject textStyleJson = new JSONObject();
        int wfcmy = 0;
        int wmy = 0;
        int wbmy = 0;
        int cwfcmy = 0;
        int cwmy = 0;
        int cwbmy = 0;
        String sql1 = "";
        String[] radius = ["35%", "50%"];
        String[] center = ["50%", "50%"];
        if (eChartDateType != 1) {
            startTime = getStartTime(eChartDateType, quarter, annual, year);
            endTime = getEndTime(eChartDateType, quarter, annual, year);
        }
        if (eChartProportion == 2 && eChartDateType != 1) {
            compareStartTime = getStartTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
            compareEndTime = getEndTime(eChartDateType, compareQuarter, compareAnnual, compareYear);
        }
        log.debug("startTime:" + startTime);
        log.debug("endTime:" + endTime);
        log.debug("compareStartTime:" + compareStartTime);
        log.debug("compareEndTime:" + compareEndTime);
        String sql = '''select
                         ifnull(sum(case when statisfaction = '1' then 1 else 0 end),0) as FCMY,
                         ifnull(sum(case when statisfaction = '2' then 1 else 0 end),0) as MY,
                         ifnull(sum(case when statisfaction = '3' then 1 else 0 end),0) as BMY
                         from tabcworkorder tabc
                         left join dg_wo_statisfaction dw on dw.objective_guid = tabc.relation_id
                         where tabc.createddate >= \'''' + startTime + '''\' 
                         and tabc.createddate <= \'''' + endTime + '''\' ''';
        List list = eliteBean.chaxun_sql(sql, DATA_SOURCE);
        if (list.size() > 0) {
            int percent = 0;
            int percent1 = 0;
            int percent2 = 0;
            JSONArray array = JSONArray.fromObject(list);
            for (int i = 0; i < array.size(); i++) {
                JSONObject object = array.get(i);
                int fcmy = object.getInt("FCMY");
                wfcmy = fcmy;
                int my = object.getInt("MY");
                wmy = my;
                int bmy = object.getInt("BMY");
                wbmy = bmy;
                if (fcmy == 0 && my == 0 && bmy == 0) {
                    percent = 0;
                    percent1 = 0;
                    percent2 = 0;
                } else {
                    percent = (fcmy / (fcmy + my + bmy)) * 100;
                    percent1 = (my / (fcmy + my + bmy)) * 100;
                    percent2 = (bmy / (fcmy + my + bmy)) * 100;
                }
                styleJson.put("text", percent + "%" + "\n" + fcmy + "人");
                styleJson.put("fontSize", 14);
                styleJson.put("fontWeight", "bold");
                styleJson2.put("text", percent1 + "%" + "\n" + my + "人");
                styleJson2.put("fontSize", 14);
                styleJson2.put("fontWeight", "bold")
                styleJson3.put("text", percent2 + "%" + "\n" + bmy + "人");
                styleJson3.put("fontSize", 14);
                styleJson3.put("fontWeight", "bold")
            }
        }
        if (eChartProportion == 2) {
            sql1 = '''select
                           ifnull(sum(case when statisfaction = '1' then 1 else 0 end),0) as FCMY,
                           ifnull(sum(case when statisfaction = '2' then 1 else 0 end),0) as MY,
                           ifnull(sum(case when statisfaction = '3' then 1 else 0 end),0) as BMY
                           from tabcworkorder tabc
                           left join dg_wo_statisfaction dw on dw.objective_guid = tabc.relation_id
                           where tabc.createddate >= \'''' + compareStartTime + '''\' 
                           and tabc.createddate <= \'''' + compareEndTime + '''\' ''';
            List listOne = eliteBean.chaxun_sql(sql1, DATA_SOURCE);
            if (listOne.size() > 0) {
                int percent = 0;
                int percent1 = 0;
                int percent2 = 0;
                JSONArray array1 = JSONArray.fromObject(listOne);
                for (int i = 0; i < array1.size(); i++) {
                    JSONObject object = array1.get(i);
                    int fcmy = object.getInt("FCMY");
                    cwfcmy = fcmy;
                    int my = object.getInt("MY");
                    cwmy = my;
                    int bmy = object.getInt("BMY");
                    cwmy = bmy;
                    if (fcmy == 0 && my == 0 && bmy == 0) {
                        percent = 0;
                        percent1 = 0;
                        percent2 = 0;
                    } else {
                        percent = (fcmy / (fcmy + my + bmy)) * 100;
                        percent1 = (my / (fcmy + my + bmy)) * 100;
                        percent2 = (bmy / (fcmy + my + bmy)) * 100;
                    }
                    styleJson4.put("text", percent + "%" + "\n" + fcmy + "人");
                    styleJson4.put("fontSize", 14);
                    styleJson4.put("fontWeight", "bold");
                    styleJson5.put("text", percent1 + "%" + "\n" + my + "人");
                    styleJson5.put("fontSize", 14);
                    styleJson5.put("fontWeight", "bold")
                    styleJson6.put("text", percent2 + "%" + "\n" + bmy + "人");
                    styleJson6.put("fontSize", 14);
                    styleJson6.put("fontWeight", "bold")
                }
            }
        }

        //拼接报文
        //第一个
        titleJson.put("text", "非常满意");
        titleJson.put("left", "center");
        titleJson.put("bottom", "auto");
        textStyleJson.put("fontSize",15);
        titleJson.put("textStyle",textStyleJson);
        eChartJson.put("title", titleJson);
        graphicJson.put("type", "text");
        graphicJson.put("left", "center");
        graphicJson.put("top", "center");
        graphicJson.put("style", styleJson);
        eChartJson.put("graphic", graphicJson);
        tooltipJson.put("trigger", "item");
        eChartJson.put("tooltip", tooltipJson);
        seriesJson.put("name", "圆环");
        seriesJson.put("type", "pie");
        seriesJson.put("radius", radius);
        seriesJson.put("center", center);
        labelLineJson.put("show", false);
        seriesJson.put("labelLine", labelLineJson);
        labelJson.put("show", false);
        seriesJson.put("label", labelJson);
        if (wfcmy > 0) {
            fcmyJson.put("name", "非常满意");
            fcmyJson.put("value", wfcmy);
            myJson.put("name", "满意");
            myJson.put("value", wmy);
            bmyJson.put("name", "不满意");
            bmyJson.put("value", wbmy);
            normalJson.put("color", "#dd5044");
            itemStyleJson.put("normal", normalJson);
            normalJson1.put("color", "#ededed");
            itemStyleJson1.put("normal", normalJson1);
            normalJson2.put("color", "#ededed");
            itemStyleJson2.put("normal", normalJson2);
            fcmyJson.put("itemStyle", itemStyleJson);
            myJson.put("itemStyle", itemStyleJson1);
            bmyJson.put("itemStyle", itemStyleJson2);
            mydArray.add(fcmyJson);
            mydArray.add(myJson);
            mydArray.add(bmyJson);
        } else {
            fcmyJson.put("name", "非常满意");
            fcmyJson.put("value", wfcmy);
            myJson.put("name", "满意");
            myJson.put("value", 0);
            bmyJson.put("name", "不满意");
            bmyJson.put("value", 0);
            normalJson.put("color", "#ededed");
            itemStyleJson.put("normal", normalJson);
            normalJson1.put("color", "#ededed");
            itemStyleJson1.put("normal", normalJson1);
            normalJson2.put("color", "#ededed");
            itemStyleJson2.put("normal", normalJson2);
            fcmyJson.put("itemStyle", itemStyleJson);
            myJson.put("itemStyle", itemStyleJson1);
            bmyJson.put("itemStyle", itemStyleJson2);
            mydArray.add(fcmyJson);
            mydArray.add(myJson);
            mydArray.add(bmyJson);
        }
        seriesJson.put("data", mydArray);
        seriesArray.add(seriesJson);
        eChartJson.put("series", seriesArray);
        resultMap.put("result1", eChartJson);
        //第二个
        titleJson2.put("text", "满意");
        titleJson2.put("left", "center");
        titleJson2.put("bottom", "auto");
        textStyleJson.put("fontSize",15);
        titleJson2.put("textStyle",textStyleJson);
        eChartJson2.put("title", titleJson2);
        graphicJson2.put("type", "text");
        graphicJson2.put("left", "center");
        graphicJson2.put("top", "center");
        graphicJson2.put("style", styleJson2);
        eChartJson2.put("graphic", graphicJson2);
        eChartJson2.put("tooltip", tooltipJson);
        seriesJson2.put("name", "圆环");
        seriesJson2.put("type", "pie");
        seriesJson2.put("radius", radius);
        seriesJson2.put("center", center);
        seriesJson2.put("labelLine", labelLineJson);
        seriesJson2.put("label", labelJson);
        if (wmy > 0) {
            fcmyJson1.put("name", "非常满意");
            fcmyJson1.put("value", wfcmy);
            myJson1.put("name", "满意");
            myJson1.put("value", wmy);
            bmyJson1.put("name", "不满意");
            bmyJson1.put("value", wbmy);
            normalJson3.put("color", "#ededed");
            itemStyleJson3.put("normal", normalJson3);
            normalJson4.put("color", "#dd5044");
            itemStyleJson4.put("normal", normalJson4);
            normalJson5.put("color", "#ededed");
            itemStyleJson5.put("normal", normalJson5);
            fcmyJson1.put("itemStyle", itemStyleJson3);
            myJson1.put("itemStyle", itemStyleJson4);
            bmyJson1.put("itemStyle", itemStyleJson5);
            mydArray1.add(fcmyJson1);
            mydArray1.add(myJson1);
            mydArray1.add(bmyJson1);
        } else {
            fcmyJson1.put("name", "非常满意");
            fcmyJson1.put("value", 0);
            myJson1.put("name", "满意");
            myJson1.put("value", wmy);
            bmyJson1.put("name", "不满意");
            bmyJson1.put("value", 0);
            normalJson3.put("color", "#ededed");
            itemStyleJson3.put("normal", normalJson3);
            normalJson4.put("color", "#ededed");
            itemStyleJson4.put("normal", normalJson4);
            normalJson5.put("color", "#ededed");
            itemStyleJson5.put("normal", normalJson5);
            fcmyJson1.put("itemStyle", itemStyleJson3);
            myJson1.put("itemStyle", itemStyleJson4);
            bmyJson1.put("itemStyle", itemStyleJson5);
            mydArray1.add(fcmyJson1);
            mydArray1.add(myJson1);
            mydArray1.add(bmyJson1);
        }
        seriesJson2.put("data", mydArray1);
        seriesArray2.add(seriesJson2);
        eChartJson2.put("series", seriesArray2);
        resultMap.put("result2", eChartJson2);
        //第三个
        titleJson3.put("text", "不满意");
        titleJson3.put("left", "center");
        titleJson3.put("bottom", "auto");
        textStyleJson.put("fontSize",15);
        titleJson3.put("textStyle",textStyleJson);
        eChartJson3.put("title", titleJson3);
        graphicJson3.put("type", "text");
        graphicJson3.put("left", "center");
        graphicJson3.put("top", "center");
        graphicJson3.put("style", styleJson3);
        eChartJson3.put("graphic", graphicJson3);
        eChartJson3.put("tooltip", tooltipJson);
        seriesJson3.put("name", "圆环");
        seriesJson3.put("type", "pie");
        seriesJson3.put("radius", radius);
        seriesJson3.put("center", center);
        seriesJson3.put("labelLine", labelLineJson);
        seriesJson3.put("label", labelJson);
        if (wbmy > 0) {
            fcmyJson2.put("name", "非常满意");
            fcmyJson2.put("value", wfcmy);
            myJson2.put("name", "满意");
            myJson2.put("value", wmy);
            bmyJson2.put("name", "不满意");
            bmyJson2.put("value", wbmy);
            normalJson6.put("color", "#ededed");
            itemStyleJson6.put("normal", normalJson6);
            normalJson7.put("color", "#ededed");
            itemStyleJson7.put("normal", normalJson7);
            normalJson8.put("color", "#dd5044");
            itemStyleJson8.put("normal", normalJson8);
            fcmyJson2.put("itemStyle", itemStyleJson6);
            myJson2.put("itemStyle", itemStyleJson7);
            bmyJson2.put("itemStyle", itemStyleJson8);
            mydArray2.add(fcmyJson2);
            mydArray2.add(myJson2);
            mydArray2.add(bmyJson2);
        } else {
            fcmyJson2.put("name", "非常满意");
            fcmyJson2.put("value", 0);
            myJson2.put("name", "满意");
            myJson2.put("value", 0);
            bmyJson2.put("name", "不满意");
            bmyJson2.put("value", wbmy);
            normalJson6.put("color", "#ededed");
            itemStyleJson6.put("normal", normalJson6);
            normalJson7.put("color", "#ededed");
            itemStyleJson7.put("normal", normalJson7);
            normalJson8.put("color", "#ededed");
            itemStyleJson8.put("normal", normalJson8);
            fcmyJson2.put("itemStyle", itemStyleJson6);
            myJson2.put("itemStyle", itemStyleJson7);
            bmyJson2.put("itemStyle", itemStyleJson8);
            mydArray2.add(fcmyJson2);
            mydArray2.add(myJson2);
            mydArray2.add(bmyJson2);
        }
        seriesJson3.put("data", mydArray2);
        seriesArray3.add(seriesJson3);
        eChartJson3.put("series", seriesArray3);
        resultMap.put("result3", eChartJson3);
        //第四个
        eChartJson4.put("title", titleJson);
        graphicJson4.put("type", "text");
        graphicJson4.put("left", "center");
        graphicJson4.put("top", "center");
        graphicJson4.put("style", styleJson4);
        eChartJson4.put("graphic", graphicJson4);
        eChartJson4.put("tooltip", tooltipJson);
        seriesJson4.put("name", "圆环");
        seriesJson4.put("type", "pie");
        seriesJson4.put("radius", radius);
        seriesJson4.put("center", center);
        seriesJson4.put("labelLine", labelLineJson);
        seriesJson4.put("label", labelJson);
        if (cwfcmy > 0) {
            fcmyJsonCompare.put("name", "非常满意");
            fcmyJsonCompare.put("value", cwfcmy);
            myJsonCompare.put("name", "满意");
            myJsonCompare.put("value", cwmy);
            bmyJsonCompare.put("name", "不满意");
            bmyJsonCompare.put("value", cwbmy);
            normalJsonCompare.put("color", "#dd5044");
            itemStyleJsonCompare.put("normal", normalJsonCompare);
            normalJson1Compare.put("color", "#ededed");
            itemStyleJson1Compare.put("normal", normalJson1Compare);
            normalJson2Compare.put("color", "#ededed");
            itemStyleJson2Compare.put("normal", normalJson2Compare);
            fcmyJsonCompare.put("itemStyle", itemStyleJsonCompare);
            myJsonCompare.put("itemStyle", itemStyleJson1Compare);
            bmyJsonCompare.put("itemStyle", itemStyleJson2Compare);
            mydArrayCompare.add(fcmyJsonCompare);
            mydArrayCompare.add(myJsonCompare);
            mydArrayCompare.add(bmyJsonCompare);
        } else {
            fcmyJsonCompare.put("name", "非常满意");
            fcmyJsonCompare.put("value", cwfcmy);
            myJsonCompare.put("name", "满意");
            myJsonCompare.put("value", 0);
            bmyJsonCompare.put("name", "不满意");
            bmyJsonCompare.put("value", 0);
            normalJsonCompare.put("color", "#ededed");
            itemStyleJsonCompare.put("normal", normalJsonCompare);
            normalJson1Compare.put("color", "#ededed");
            itemStyleJson1Compare.put("normal", normalJson1Compare);
            normalJson2Compare.put("color", "#ededed");
            itemStyleJson2Compare.put("normal", normalJson2Compare);
            fcmyJsonCompare.put("itemStyle", itemStyleJsonCompare);
            myJsonCompare.put("itemStyle", itemStyleJson1Compare);
            bmyJsonCompare.put("itemStyle", itemStyleJson2Compare);
            mydArrayCompare.add(fcmyJsonCompare);
            mydArrayCompare.add(myJsonCompare);
            mydArrayCompare.add(bmyJsonCompare);
        }
        seriesJson4.put("data", mydArrayCompare);
        seriesArray4.add(seriesJson4);
        eChartJson4.put("series", seriesArray4);
        resultMap.put("result4", eChartJson4);
        //第五个
        eChartJson5.put("title", titleJson2);
        graphicJson5.put("type", "text");
        graphicJson5.put("left", "center");
        graphicJson5.put("top", "center");
        graphicJson5.put("style", styleJson5);
        eChartJson5.put("graphic", graphicJson5);
        eChartJson5.put("tooltip", tooltipJson);
        seriesJson5.put("name", "圆环");
        seriesJson5.put("type", "pie");
        seriesJson5.put("radius", radius);
        seriesJson5.put("center", center);
        seriesJson5.put("labelLine", labelLineJson);
        seriesJson5.put("label", labelJson);
        if (cwmy > 0) {
            fcmyJsonCompare1.put("name", "非常满意");
            fcmyJsonCompare1.put("value", cwfcmy);
            myJsonCompare1.put("name", "满意");
            myJsonCompare1.put("value", cwmy);
            bmyJsonCompare1.put("name", "不满意");
            bmyJsonCompare1.put("value", cwbmy)
            normalJson3Compare.put("color", "#ededed");
            itemStyleJson3Compare.put("normal", normalJson3Compare);
            normalJson4Compare.put("color", "#dd5044");
            itemStyleJson4Compare.put("normal", normalJson4Compare);
            normalJson5Compare.put("color", "#ededed");
            itemStyleJson5Compare.put("normal", normalJson5Compare);
            fcmyJsonCompare1.put("itemStyle", itemStyleJson3Compare);
            myJsonCompare1.put("itemStyle", itemStyleJson4Compare);
            bmyJsonCompare1.put("itemStyle", itemStyleJson5Compare);
            mydArrayCompare1.add(fcmyJsonCompare1);
            mydArrayCompare1.add(myJsonCompare1);
            mydArrayCompare1.add(bmyJsonCompare1);
        } else {
            fcmyJsonCompare1.put("name", "非常满意");
            fcmyJsonCompare1.put("value", 0);
            myJsonCompare1.put("name", "满意");
            myJsonCompare1.put("value", cwmy);
            bmyJsonCompare1.put("name", "不满意");
            bmyJsonCompare1.put("value", 0);
            normalJson3Compare.put("color", "#ededed");
            itemStyleJson3Compare.put("normal", normalJson3Compare);
            normalJson4Compare.put("color", "#ededed");
            itemStyleJson4Compare.put("normal", normalJson4Compare);
            normalJson5Compare.put("color", "#ededed");
            itemStyleJson5Compare.put("normal", normalJson5Compare);
            fcmyJsonCompare1.put("itemStyle", itemStyleJson3Compare);
            myJsonCompare1.put("itemStyle", itemStyleJson4Compare);
            bmyJsonCompare1.put("itemStyle", itemStyleJson5Compare);
            mydArrayCompare1.add(fcmyJsonCompare1);
            mydArrayCompare1.add(myJsonCompare1);
            mydArrayCompare1.add(bmyJsonCompare1);
        }
        seriesJson5.put("data", mydArrayCompare1);
        seriesArray5.add(seriesJson5);
        eChartJson5.put("series", seriesArray5);
        resultMap.put("result5", eChartJson5);
        //第六个
        eChartJson6.put("title", titleJson3);
        graphicJson6.put("type", "text");
        graphicJson6.put("left", "center");
        graphicJson6.put("top", "center");
        graphicJson6.put("style", styleJson6);
        eChartJson6.put("graphic", graphicJson6);
        eChartJson6.put("tooltip", tooltipJson);
        seriesJson6.put("name", "圆环");
        seriesJson6.put("type", "pie");
        seriesJson6.put("radius", radius);
        seriesJson6.put("center", center);
        seriesJson6.put("labelLine", labelLineJson);
        seriesJson6.put("label", labelJson);
        if (cwbmy > 0) {
            fcmyJsonCompare2.put("name", "非常满意");
            fcmyJsonCompare2.put("value", cwfcmy);
            myJsonCompare2.put("name", "满意");
            myJsonCompare2.put("value", cwmy);
            bmyJsonCompare2.put("name", "不满意");
            bmyJsonCompare2.put("value", cwbmy)
            normalJson6Compare.put("color", "#ededed");
            itemStyleJson6Compare.put("normal", normalJson6Compare);
            normalJson7Compare.put("color", "#ededed");
            itemStyleJson7Compare.put("normal", normalJson7Compare);
            normalJson8Compare.put("color", "#dd5044");
            itemStyleJson8Compare.put("normal", normalJson8Compare);
            fcmyJsonCompare2.put("itemStyle", itemStyleJson6Compare);
            myJsonCompare2.put("itemStyle", itemStyleJson7Compare);
            bmyJsonCompare2.put("itemStyle", itemStyleJson8Compare);
            mydArrayCompare2.add(fcmyJsonCompare2);
            mydArrayCompare2.add(myJsonCompare2);
            mydArrayCompare2.add(bmyJsonCompare2);
        } else {
            fcmyJsonCompare2.put("name", "非常满意");
            fcmyJsonCompare2.put("value", 0);
            myJsonCompare2.put("name", "满意");
            myJsonCompare2.put("value", 0);
            bmyJsonCompare2.put("name", "不满意");
            bmyJsonCompare2.put("value", cwbmy);
            normalJson6Compare.put("color", "#ededed");
            itemStyleJson6Compare.put("normal", normalJson6Compare);
            normalJson7Compare.put("color", "#ededed");
            itemStyleJson7Compare.put("normal", normalJson7Compare);
            normalJson8Compare.put("color", "#ededed");
            itemStyleJson8Compare.put("normal", normalJson8Compare);
            fcmyJsonCompare2.put("itemStyle", itemStyleJson6Compare);
            myJsonCompare2.put("itemStyle", itemStyleJson7Compare);
            bmyJsonCompare2.put("itemStyle", itemStyleJson8Compare);
            mydArrayCompare2.add(fcmyJsonCompare2);
            mydArrayCompare2.add(myJsonCompare2);
            mydArrayCompare2.add(bmyJsonCompare2);
        }
        seriesJson6.put("data", mydArrayCompare2);
        seriesArray6.add(seriesJson6);
        eChartJson6.put("series", seriesArray6);
        resultMap.put("result6", eChartJson6);
        return resultMap;
    }


    /**
     * 根据时间类型获取开始时间
     * @param eChartDateType
     * @return 开始时间
     */
    String getStartTime(int eChartDateType, int quarter, int annual, int year) {
        String startTime = "";
        if (eChartDateType == 2) { //季度
            switch (quarter) { //季度判断
                case 1: //一季度
                    startTime = year + "-01-01 00:00:00";
                    break;
                case 2: //二季度
                    startTime = year + "-04-01 00:00:00";
                    break;
                case 3: //三季度
                    startTime = year + "-07-01 00:00:00";
                    break;
                case 4: //四季度
                    startTime = year + "-10-01 00:00:00";
                    break;
            }
        } else if (eChartDateType == 3) { //半年度
            switch (annual) { //半年度判断
                case 1: //上半年
                    startTime = year + "-01-01 00:00:00";
                    break;
                case 2: //下班年
                    startTime = year + "-07-01 00:00:00";
                    break;
            }
        } else if (eChartDateType == 4) {
            startTime = year + "-01-01 00:00:00";
        }
        return startTime;
    }

    /**
     * 根据时间类型获取环比开始时间
     * @param eChartDateType
     * @return 开始时间
     */
    String getStartTime(int eChartDateType, int quarter, int annual, int year, int month) {
        String startTime = "";
        if (eChartDateType == 1) {
            switch (month) {
                case 1:
                    startTime = (year - 1) + "-12-01 00:00:00";
                    break;
                case 2:
                    startTime = year + "-01-01 00:00:00";
                    break;
                case 3:
                    startTime = year + "-02-01 00:00:00";
                    break;
                case 4:
                    startTime = year + "-03-01 00:00:00";
                    break;
                case 5:
                    startTime = year + "-04-01 00:00:00";
                    break;
                case 6:
                    startTime = year + "-05-01 00:00:00";
                    break;
                case 7:
                    startTime = year + "-06-01 00:00:00";
                    break;
                case 8:
                    startTime = year + "-07-01 00:00:00";
                    break;
                case 9:
                    startTime = year + "-08-01 00:00:00";
                    break;
                case 10:
                    startTime = year + "-09-01 00:00:00";
                    break;
                case 11:
                    startTime = year + "-10-01 00:00:00";
                    break;
                case 12:
                    startTime = year + "-11-01 00:00:00";
                    break;
            }
        } else if (eChartDateType == 2) { //季度
            switch (quarter) { //季度判断
                case 1: //一季度
                    startTime = (year - 1) + "-09-01 00:00:00";
                    break;
                case 2: //二季度
                    startTime = year + "-01-01 00:00:00";
                    break;
                case 3: //三季度
                    startTime = year + "-04-01 00:00:00";
                    break;
                case 4: //四季度
                    startTime = year + "-07-01 00:00:00";
            }
        } else if (eChartDateType == 3) { //半年度
            switch (annual) { //半年度判断
                case 1: //上半年
                    startTime = (year - 1) + "-07-01 00:00:00";
                    break;
                case 2: //下半年
                    startTime = year + "-01-01 00:00:00";
                    break;
            }
        } else if (eChartDateType == 4) {
            startTime = (year - 1) + "-01-01 00:00:00";
        }
        return startTime;
    }

    /**
     * 根据时间类型获取结束时间
     * @param eChartDateType
     * @return 结束时间
     */
    String getEndTime(int eChartDateType, int quarter, int annual, int year) {
        String endTime = "";
        if (eChartDateType == 2) { //季度
            switch (quarter) { //季度判断
                case 1: //一季度
                    endTime = year + "-03-31 23:59:59";
                    break;
                case 2: //二季度
                    endTime = year + "-06-30 23:59:59";
                    break;
                case 3: //三季度
                    endTime = year + "-09-30 23:59:59";
                    break;
                case 4: //四季度
                    endTime = year + "-12-31 23:59:59";
                    break;
            }
        } else if (eChartDateType == 3) { //半年度
            switch (annual) { //半年度判断
                case 1: //上半年
                    endTime = year + "-06-30 23:59:59";
                    break;
                case 2: //下班年
                    endTime = year + "-12-31 23:59:59";
                    break;
            }
        } else if (eChartDateType == 4) {
            endTime = year + "-12-31 23:59:59";
        }
        return endTime;
    }

    /**
     * 根据时间类型获取环比结束时间
     * @param eChartDateType
     * @return 结束时间
     */
    String getEndTime(int eChartDateType, int quarter, int annual, int year, int month) {
        String endTime = "";
        if (eChartDateType == 1) {
            switch (month) {
                case 1:
                    endTime = (year - 1) + "-12-31 23:59:59";
                    break;
                case 2:
                    endTime = year + "-01-31 23:59:59";
                    break;
                case 3:
                    endTime = year + "-02-31 23:59:59";
                    break;
                case 4:
                    endTime = year + "-03-31 23:59:59";
                    break;
                case 5:
                    endTime = year + "-04-31 23:59:59";
                    break;
                case 6:
                    endTime = year + "-05-31 23:59:59";
                    break;
                case 7:
                    endTime = year + "-06-31 23:59:59";
                    break;
                case 8:
                    endTime = year + "-07-31 23:59:59";
                    break;
                case 9:
                    endTime = year + "-08-31 23:59:59";
                    break;
                case 10:
                    endTime = year + "-09-31 23:59:59";
                    break;
                case 11:
                    endTime = year + "-10-31 23:59:59";
                    break;
                case 12:
                    endTime = year + "-11-31 23:59:59";
                    break;
            }
        } else if (eChartDateType == 2) { //季度
            switch (quarter) { //季度判断
                case 1: //一季度
                    endTime = (year - 1) + "-12-31 23:59:59";
                    break;
                case 2: //二季度
                    endTime = year + "-03-31 23:59:59";
                    break;
                case 3: //三季度
                    endTime = year + "-06-30 23:59:59";
                    break;
                case 4: //四季度
                    endTime = year + "-09-30 23:59:59";
            }
        } else if (eChartDateType == 3) { //半年度
            switch (annual) { //半年度判断
                case 1: //上半年
                    endTime = (year - 1) + "-12-31 23:59:59";
                    break;
                case 2: //下半年
                    endTime = year + "-06-30 23:59:59";
                    break;
            }
        } else if (eChartDateType == 4) {
            endTime = (year - 1) + "-12-31 23:59:59";
        }
        return endTime;
    }



    /**
     * 获得选择时间的翻译
     * @param getTimeDesc
     * @return String
     */
    String getTimeDesc(EliteBean eliteBean,String dateString, int datetimetype) {
        String datedesc = "";
        if(datetimetype==1){
            List datelist = eliteBean.chaxun_sql("select months from year_months where months='"+dateString+"'", DATA_SOURCE);
            if(datelist.size()>0){
                datedesc=datelist.get(0).get("months");
            }
        }

        if(datetimetype==2){
            List datelist = eliteBean.chaxun_sql("select quarterdesc from year_quarter where yearquarter='"+dateString+"'", DATA_SOURCE);
            if(datelist.size()>0){
                datedesc=datelist.get(0).get("quarterdesc");
            }
        }


        if(datetimetype==3){
            List datelist = eliteBean.chaxun_sql(" select year_halfdesc from  year_half where year_half='"+dateString+"'", DATA_SOURCE);
            if(datelist.size()>0){
                datedesc=datelist.get(0).get("year_halfdesc");
            }
        }



        if(datetimetype==4){
            List datelist = eliteBean.chaxun_sql(" select yeardesc from  year_d where yearid='"+dateString+"'", DATA_SOURCE);
            if(datelist.size()>0){
                datedesc=datelist.get(0).get("yeardesc");
            }
        }

        return datedesc;
    }

}